Skip to content

Commit 6dd49cd

Browse files
author
Aaron Imming
committed
Create global state in observer
1 parent 6d5521d commit 6dd49cd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/common/utils/observer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Map, List } from 'immutable';
33
export default class Observer {
44
constructor() {
55
this.eam = new Map(); // event action map
6+
this.state = {};
67
}
78
register(event, _action, once, unregisterIfError, unregisterAllBefore) {
89
if (unregisterAllBefore) {
@@ -53,6 +54,12 @@ export default class Observer {
5354
this.eam.get(event).forEach(action => action.action(data));
5455
}
5556
}
57+
setState(state = {}) {
58+
this.state = Object.assign({}, this.state, state);
59+
}
60+
getState(key) {
61+
return this.state[key];
62+
}
5663
}
5764

5865
export const observer = new Observer();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy