From dd1d3d84df28e24c51be9fd8b367b1fcf5141dd5 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 6 Dec 2023 22:29:26 -0500
Subject: created basic state machine for info ui.

---
 .../CollectionFreeFormInfoState.tsx                | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx')

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>;
+    }
+}
-- 
cgit v1.2.3-70-g09d2

