Skip to content
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

Type the event manager and the map.updateLayer event #798

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

tahini
Copy link
Collaborator

@tahini tahini commented Dec 6, 2023

  • eventManager: Add methods to listen and emit typed events

This allows to use a type for the events, with a name and args fields for the name of the event and types of arguments in the callback.

The methods are generic, with the generic type being the type of the event. The listening method is onEvent, the emitting one is emitEvent. It can be called in the code with

eventManager.emitEvent<MyEventType>('event.myevent', myArgs)
eventManager.onEvent<MyEventType>('event.myevent', (myArgs) => void)

  • map: type the map.updateLayer event

Use the new onEvent and emitEvent methods of the EventManager to type the calls to map.updateLayer. It receives an argument with 2 fields: layerName and data, which are respectively the layer to update and the geojson feature collection for the layer (or function to retrieve it).

@tahini tahini requested a review from kaligrafy December 6, 2023 03:48
This allows to use a type for the events, with a `name` and `args`
fields for the name of the event and types of arguments in the callback.

The methods are generic, with the generic type being the type of the
event. The listening method is `onEvent`, the emitting one is
`emitEvent`. It can be called in the code with

`eventManager.emitEvent<MyEventType>('event.myevent', myArgs)`
`eventManager.onEvent<MyEventType>('event.myevent', (myArgs) => void)`

Add unit tests for these new methods.
Use the new `onEvent` and `emitEvent` methods of the EventManager to
type the calls to `map.updateLayer`. It receives an argument with 2
fields: `layerName` and `data`, which are respectively the layer to
update and the geojson feature collection for the layer (or function
to retrieve it).
@tahini
Copy link
Collaborator Author

tahini commented Dec 20, 2023

@kaligrafy ping on this review

@tahini tahini merged commit 4c87641 into chairemobilite:main Dec 20, 2023
4 checks passed
@tahini tahini deleted the typeEventManager branch December 20, 2023 23:39
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.

2 participants