forked from Kitware/visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Redux): Replace data management with a Redux based one
BREAKING CHANGE: The client needs ParaView 5.2 or newer
- Loading branch information
Showing
60 changed files
with
3,468 additions
and
655 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
const DEFAULT_IMAGE_PROVIDER = 'default'; | ||
const providers = {}; | ||
const listeners = {}; | ||
|
||
export function setImageProvider(provider, key) { | ||
providers[key || DEFAULT_IMAGE_PROVIDER] = provider; | ||
const listenersToNotify = listeners[key || DEFAULT_IMAGE_PROVIDER] || []; | ||
listenersToNotify.forEach(cb => { | ||
if (cb) { | ||
cb(provider); | ||
} | ||
}); | ||
delete listeners[key || DEFAULT_IMAGE_PROVIDER]; | ||
} | ||
|
||
export function getImageProvider(key) { | ||
return providers[key || DEFAULT_IMAGE_PROVIDER]; | ||
} | ||
|
||
export function onImageProvider(callback, key = DEFAULT_IMAGE_PROVIDER) { | ||
if (providers[key]) { | ||
callback(providers[key]); | ||
return -1; | ||
} | ||
|
||
if (!listeners[key]) { | ||
listeners[key] = []; | ||
} | ||
const id = listeners[key].length; | ||
listeners[key].push(callback); | ||
|
||
return id; | ||
} | ||
|
||
export function unsubscribe(id, key = DEFAULT_IMAGE_PROVIDER) { | ||
listeners[key][id] = null; | ||
} | ||
|
||
export default { | ||
setImageProvider, | ||
getImageProvider, | ||
onImageProvider, | ||
unsubscribe, | ||
}; |
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
Oops, something went wrong.