import * as React from 'react'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import renderer from '@platform/electron/lib/renderer'; import * as cli from '../cli'; import { CommandShell, t, ObjectView, Hr } from '../common'; export type ITestProps = {}; export class Test extends React.PureComponent { public state: t.ITestState = {}; private unmounted$ = new Subject(); private state$ = new Subject>(); private cli!: t.ICommandState; public static contextType = renderer.Context; public context!: renderer.ReactContext; /** * [Lifecycle] */ public componentWillMount() { const state$ = this.state$.pipe(takeUntil(this.unmounted$)); state$.subscribe(e => this.setState(e)); this.cli = cli.init({ ipc: this.context.ipc, state$: this.state$, getState: () => this.state, }); } public componentWillUnmount() { this.unmounted$.next(); this.unmounted$.complete(); } /** * [Render] */ public render() { return (
{this.state.current}

); } }