Skip to content
Snippets Groups Projects
Select Git revision
  • ed31e06c06c56ad0f95c47af11d71862fd8b2ecb
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

compiler.ts

Blame
  • controller.ts 1.18 KiB
    /*
     * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * Adapted from LiteMol
     * Copyright (c) 2016 - now David Sehnal, licensed under Apache 2.0, See LICENSE file for more info.
     */
    
    import { BehaviorSubject } from 'rxjs';
    import { merge } from 'mol-util';
    import { Context } from '../context/context'
    import { LayoutRegion } from './layout';
    
    export class Controller<State> {
    
        private _state = new BehaviorSubject<State>(<any>void 0);
        private _latestState: State = <any>void 0;
    
        get dispatcher() {
            return this.context.dispatcher;
        }
    
        setState(...states: Partial<State>[]) {
            let s = merge(this._latestState, ...states);
            if (s !== this._latestState) {
                this._latestState = s;
                this._state.next(s);
            }
        }
    
        get state() {
            return this._state;
        }
    
        get latestState() {
            return this._latestState;
        }
    
        constructor(public context: Context, initialState: State) {
            this._latestState = initialState;
        }
    }
    
    export interface ControllerInfo {
        key: string;
        controller: Controller<any>;
        view: any;
        region: LayoutRegion;
        isStatic?: boolean;
    }