Eliminate Source#on{Add,Remove}(map)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
The main use of `on{Add,Remove}(map)` in source subclasses is to store a reference to the map for later use. This introduces both statefulness (certain source operations work only after `onAdd` has been called) and tight coupling between a source and the map.
Instead, sources should be passed the things to which they need access as parameters to the relevant methods.
Ref https://github.com/mapbox/mapbox-gl-js/pull/3255#discussion_r80765491
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Source subclasses and all onAdd/onRemove(map) call sites, then read the linked pull request discussion for the intended boundaries. Done means sources no longer retain map references through these hooks and the relevant source operations receive their dependencies as method parameters, with existing behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100