Skip to content

Conversation

@R-lagoman
Copy link
Contributor

@R-lagoman R-lagoman commented Nov 19, 2025

Expoñemos a través dunha callback todas as mensaxes do viewer.
Método para uso interno, publicado como tal.
Ollo cambiar versión (beta) antes de mergear!

@R-lagoman R-lagoman changed the title Feature/pro 4276 ar Feature/pro 4276 AR Nov 19, 2025
}

/**
* Represents a message from the map viewer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Máis que o "message" representa o callback que pode xestionar o "message" no?

O nome fáiseme algo raro, o concepto de delegate en react non se suele utilizar. Quizais debería ser algo tipoOnInternalMapViewMessageCallback?

} from "../store";
import { useSelector } from "../store/utils";
import {
OnInternalMapViewMessageDelegate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { type OnInternalMapViewMessageDelegate ...}

/**
* Internal callback invoked with every MapView message.
*/
onInternalMapViewMessageDelegate: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

que esto este na API pública é un pouco raro :(

Podríamos crear unha interfaz privada para separalo? Aínda que sexa accesible desde fóra, os métodos internos quedarían moito menos expostos.

A miña proposta sería algo así.

  1. Crear unha interfaz internal:
import type { MapViewRef } from "./index";

/**
 * @internal Mark this an internal
 */
export interface OnInternalMapViewMessageCallback {
  (type: string, payload: any): void;
}

/**
 * @internal Mark this an internal
 */
export interface InternalMapViewRef extends MapViewRef {
  /**
   * @internal Mark this as internal
   */
  setOnInternalMapViewMessageCallback: (
    delegate: OnInternalMapViewMessageCallback,
  ) => void;
}

Internalmente MapView.tsx utiliza esta interfaz, pero sólo ao instanciar useImperativeHandler que se usa de forma interna

useImperativeHandle(ref, (): InternalMapViewRef => {
...

Despois dende un módulo externo podríase facer algo como:

const mapViewRef = useRef<InternalMapViewRef>(null);

useEffect(() => {
   mapViewRef.current?.setOnInternalMapViewMessageDelegate((type, payload) => {
      ...
    });
}, [mapViewRef])

Pero xa tes que saber que existe InternalMapViewRef

const webViewRef = useRef<WebView>(null);
const [_onDirectionsRequestInterceptor, setInterceptor] =
useState<OnDirectionsRequestInterceptor>();
const internalMessageDelegateRef =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O mesmo que comentei na definición de tipados, en React suélese utilizar internalMessageCallbackRef

* @param poiId You can obtain the identifiers of your POIs by retrieving them with [SitumPlugin.fetchIndoorPOIsFromBuilding()](https://developers.situm.com/sdk_documentation/react-native/typedoc/classes/default.html#fetchIndoorPOIsFromBuilding).
*/
selectPoi: (poiId: number) => void;
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este método parece que estaba implementado, pero non estaba na interface... TS colaba igual...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants