* ui: fix performance bottlenecks, split data sources in devtools panes * ui: move xray warn * Player ux improvements (#2834) * Player UX improvements. DevTools (Including multi-tab) Actions panel (User events, Click maps, Tag Elements) * ui: remove unused imports, remove str templ classnames --------- Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com> --------- Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
18 lines
550 B
TypeScript
18 lines
550 B
TypeScript
import { Store } from './types'
|
|
|
|
export default class SimpleStore<G extends Record<string, any>, S extends Record<string, any> = G> implements Store<G, S> {
|
|
constructor(private state: G){}
|
|
get(): G {
|
|
return this.state
|
|
}
|
|
update = (newState: Partial<S>) => {
|
|
Object.assign(this.state, newState)
|
|
}
|
|
updateTabStates = (id: string, newState: Partial<S>) => {
|
|
try {
|
|
Object.assign(this.state.tabStates[id], newState)
|
|
} catch (e) {
|
|
console.log('Error updating tab state', e, id, newState, this.state, this)
|
|
}
|
|
}
|
|
}
|