diff options
| author | bobzel <zzzman@gmail.com> | 2023-12-06 22:29:26 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2023-12-06 22:29:26 -0500 |
| commit | dd1d3d84df28e24c51be9fd8b367b1fcf5141dd5 (patch) | |
| tree | 21cc42c79abdd5e9a11c55db5044ebe5778b9f4c /src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx | |
| parent | 75915bfb1699959c9684a19d93389f8a9cb4518a (diff) | |
created basic state machine for info ui.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx new file mode 100644 index 000000000..bf47820a1 --- /dev/null +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx @@ -0,0 +1,51 @@ +import { IReactionDisposer, reaction } from 'mobx'; +import { observer } from 'mobx-react'; +import './CollectionFreeFormView.scss'; +import React = require('react'); + +export type infoArc = { + events: () => any; + actions: (arg?: any) => any; +}; +export class infoState { + Message: string = ''; + Arcs: infoArc[] = []; + constructor(message: string, arcs: infoArc[]) { + this.Message = message; + this.Arcs = arcs; + } +} + +export interface CollectionFreeFormInfoStateProps { + state: infoState; +} + +@observer +export class CollectionFreeFormInfoState extends React.Component<CollectionFreeFormInfoStateProps> { + _disposers: IReactionDisposer[] = []; + componentDidMount(): void { + this._disposers = this.props.state.Arcs.map(arc => + reaction( + () => arc.events(), + args => arc.actions(args), + { fireImmediately: true } + ) + ); + } + componentWillUpdate() { + this._disposers.map(disposer => disposer()); + this._disposers = this.props.state.Arcs.map(arc => + reaction( + () => arc.events(), + args => arc.actions(args), + { fireImmediately: true } + ) + ); + } + componentWillUnmount(): void { + this._disposers.map(disposer => disposer()); + } + render() { + return <div className="infoUI">{this.props.state.Message}</div>; + } +} |
