Download js/ui_state/lib/component.js from flowers-team/Interactive_DeepRL_Demo: direct link, hf CLI and curl.
- Browser
- Download file 695 Bytes
-
https://huggingface.co/spaces/flowers-team/Interactive_DeepRL_Demo/resolve/main/js/ui_state/lib/component.js
- Command line
-
hf download hf://spaces/flowers-team/Interactive_DeepRL_Demo/js/ui_state/lib/component.js
-
curl -L -o component.js https://huggingface.co/spaces/flowers-team/Interactive_DeepRL_Demo/resolve/main/js/ui_state/lib/component.js
695 Bytes
| import Store from '../store/store.js'; | |
| /** | |
| * @classdesc Abstract class for UI components. | |
| */ | |
| export default class Component { | |
| /** | |
| * @constructor | |
| * @param props {{store: Store, element: HTMLElement, eventName: string}} | |
| */ | |
| constructor(props = {}) { | |
| this.render = this.render || function () { }; | |
| // Adds props.eventName with this.render() as callback function to the list of events handled by the UI state manager | |
| if (props.store instanceof Store) { | |
| props.store.events.subscribe(props.eventName, () => this.render()); | |
| } | |
| if (props.hasOwnProperty('element')) { | |
| this.element = props.element; | |
| } | |
| } | |
| } |