-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(POI Map): add
zoom
and center
options
Additional minors changes - fix(POI Map): update bbox only when its value changes Not when a change occurs in the `options` object - fix(POI Map): remove default bbox
- Loading branch information
1 parent
a123107
commit 7a6eaae
Showing
7 changed files
with
131 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { isEqual } from 'lodash'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { writable } from 'svelte/store'; | ||
|
||
/** | ||
* Creates a Svelte writable store that compares values deeply before updating. | ||
* | ||
* @param initialValue - The initial value for the store. | ||
* @returns An object containing the subscribe and set methods. | ||
*/ | ||
const createDeepEqual = <V>(initialValue: V | undefined) => { | ||
const { subscribe, update: internalUpdate } = writable<V | undefined>(initialValue); | ||
|
||
return { | ||
/** | ||
* Subscribes to changes in the store's value. | ||
*/ | ||
subscribe, | ||
/** | ||
* Update the store value if the new value differs from the store current value | ||
* by performing a deep comparison. | ||
*/ | ||
update: (newValue?: V | undefined) => { | ||
internalUpdate((storeValue: V | undefined) => { | ||
// Won't trigger subcribers | ||
if (isEqual(storeValue, newValue)) return storeValue; | ||
return newValue; | ||
}); | ||
}, | ||
}; | ||
}; | ||
|
||
export default createDeepEqual; |