當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mobx.observable類代碼示例

本文整理匯總了TypeScript中mobx.observable的典型用法代碼示例。如果您正苦於以下問題:TypeScript observable類的具體用法?TypeScript observable怎麽用?TypeScript observable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了observable類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor(graph: Remath, initialState?: INodeState) {
    super(initialState);
    this._graph = graph;
    this._id = (initialState && initialState.id) || genId();
    this._providers = observable.map<INode>();
    this._dependents = observable.map<INode>();
 }
開發者ID:trevorhanus,項目名稱:reMath,代碼行數:7,代碼來源:Node.ts

示例2: constructor

 public constructor(props: KeyToYubiKeyProps) {
   this.fingerprint = props.fingerprint;
   this.card_id = props.card_id;
   this.slot_id = observable.box(props.slot_id);
   this.passphrase = observable.box(props.passphrase);
   this.admin_pin = props.admin_pin || new Pin();
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:7,代碼來源:key-to-yubikey.ts

示例3: constructor

 public constructor(props: PinProps = {}) {
   if (props.pin) {
     this.pin = observable.box(props.pin);
   } else if (props._pin) {
     this.pin = props._pin;
   } else {
     this.pin = observable.box('');
   }
   this.match = props.match || new RegExp(PinDefaultRegex);
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:10,代碼來源:pin.ts

示例4: constructor

 constructor(val?: boolean|NestedFlag, value = false) {
   super('NestedFlag');
   this.children = [];
   if (typeof(val) == 'boolean' || !val) {
     this.parent = undefined;
     this.value = observable.box(!!val);
   } else {
     this.parent = val;
     this.parent.children.push(this);
     this.value = observable.box(undefined);
   }
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:12,代碼來源:nested-flag.ts

示例5: it

    it('Adding variable whose formula references a non-existent symbol', () => {
        const remath = new Remath();
        let view: ObservableMap<string> = observable.map<string>();
        const render = sinon.spy(() => {
            renderCells(remath, view);
        });
        autorun(render);

        // add a
        const a = remath.addCell({
            symbol: 'a',
            formula: '= b + 10'
        });
        expect(render.callCount).to.equal(2);
        expect(view.get('a')).to.equal('sym:a,formula:b + 10,val:NaN,disp:#REF?');

        // add b = 30
        runInAction(() => {
            const b = remath.addCell({
                symbol: 'b',
                formula: '=30'
            });
        });
        expect(view.get('b')).to.equal('sym:b,formula:30,val:30,disp:30');
        expect(view.get('a')).to.equal('sym:a,formula:b + 10,val:40,disp:40');
    });
開發者ID:trevorhanus,項目名稱:reMath,代碼行數:26,代碼來源:Integration_1.test.ts

示例6: constructor

 constructor(warrent: Warrent/* , contentReg = '.' */) {
   super('ViewWarrent');
   this.warrent = warrent;
   // this.contentReg = contentReg;
   this._approved = observable.box(false);
   // this.min = 0;
   // this.max = 0;
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:8,代碼來源:view-warrent.ts

示例7: constructor

 public constructor(v: Date, e: string) {
   super('DateValue');
   this.errText = e;
   this.date = observable.box(undefined);
   this.date.observe(action((chg: IValueDidChange<Date>) => {
     const f = format_date(chg.newValue);
     this.formatDate.set(f);
     // chg.newValue.setHours(0);
     // chg.newValue.setMinutes(0);
     // chg.newValue.setSeconds(0);
     // chg.newValue.setMilliseconds(0);
     // console.log('observe fix', chg.newValue);
   }));
   this.formatDate = observable.box(undefined);
   this.formatDate.observe(action((chg: IValueDidChange<string>) => {
     this.date.set(new Date(chg.newValue));
   }));
   action(() => this.formatDate.set(format_date(v)))();
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:19,代碼來源:date-value.ts

示例8: it

    it('throws if an undo instance is called twice', () => {
        let object = observable.map({ key: 2 });
        let undoableAction = action('updateMap')(() => {
            object.set('key', 5);
        });

        let undoResult = createUndo('updateMap')(undoableAction);
        undoResult();

        expect(undoResult).toThrow();
    });
開發者ID:Microsoft,項目名稱:satcheljs,代碼行數:11,代碼來源:createUndoTests.ts

示例9: constructor

 constructor(warrents: Warrents, diceWares: DiceWare[], smartCardId: string) {
   this.warrents = warrents;
   this.smartCardId = observable.box(smartCardId);
   this.readOnly = new NestedFlag(false);
   this.common = new SimpleKeyCommon(warrents, this.readOnly);
   this.passPhrase = PassPhrase.createDoublePasswords(8, new Warrents(this.warrents.map(w => w)), diceWares,
     CharFormat.wildcard(), 'PassPhrase error', ' ', 1);
   this.adminKey = PassPhrase.createPerWarrent(new Warrents(this.warrents.map(w => w)), null,
     CharFormat.decNumber(), 'adminpin error', '', 8, 8);
   const me = (new Warrents()).add(warrents.first());
   this.userKey = PassPhrase.createPerWarrent(me, null, CharFormat.decNumber(), 'userPin Error', '', 6, 8);
 }
開發者ID:mabels,項目名稱:clavator,代碼行數:12,代碼來源:simple-yubikey.ts


注:本文中的mobx.observable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。