-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/pro 4276 AR #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/pro 4276 AR #572
Conversation
plugin/src/wayfinding/types/index.ts
Outdated
| } | ||
|
|
||
| /** | ||
| * Represents a message from the map viewer. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { type OnInternalMapViewMessageDelegate ...}
plugin/src/wayfinding/types/index.ts
Outdated
| /** | ||
| * Internal callback invoked with every MapView message. | ||
| */ | ||
| onInternalMapViewMessageDelegate: ( |
There was a problem hiding this comment.
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í.
- 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 = |
There was a problem hiding this comment.
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; | ||
| /** |
There was a problem hiding this comment.
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...
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!