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


TypeScript mobx.action函數代碼示例

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


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

示例1: it

    it('should auto save on change, with a delay', function () {
      const product = new Product();

      action('change product', () => product.name = 'change 1')();
      action('change product again', () => product.name = 'change 2')();
      clock.tick(Product.autoSaveDelay);

      expect(saveSpy).to.have.been.calledOnce;
      expect(saveSpy.args[0][0].name).to.equal('change 2');
    });
開發者ID:Xristinaaaa,項目名稱:Telerik2016,代碼行數:10,代碼來源:Product-spec.ts

示例2: getPrivateActionId

export default function mutator<T extends ActionMessage>(
    actionCreator: ActionCreator<T>,
    target: MutatorFunction<T>
): MutatorFunction<T> {
    let actionId = getPrivateActionId(actionCreator);
    if (!actionId) {
        throw new Error('Mutators can only subscribe to action creators.');
    }

    // Wrap the callback in a MobX action so it can modify the store
    let wrappedTarget = action((actionMessage: T) => {
        try {
            getGlobalContext().inMutator = true;
            if (target(actionMessage) as any) {
                throw new Error('Mutators cannot return a value and cannot be async.');
            }
        } finally {
            getGlobalContext().inMutator = false;
        }
    });

    // Subscribe to the action
    subscribe(actionId, wrappedTarget);

    return target;
}
開發者ID:Microsoft,項目名稱:satcheljs,代碼行數:26,代碼來源:mutator.ts

示例3:

 return cacheQueries.map(query=>{
     const molecularProfileId = query.molecularProfileId;
     const gene = query.hugoGeneSymbol;
     const data = oncoprint.props.store.geneMolecularDataCache.result!.get(query)!.data!;
     return {
         key: `HEATMAPTRACK_${molecularProfileId},${gene}`,
         label: gene,
         molecularProfileId: molecularProfileId,
         molecularAlterationType: molecularProfileIdToMolecularProfile[molecularProfileId].molecularAlterationType,
         datatype: molecularProfileIdToMolecularProfile[molecularProfileId].datatype,
         data: makeHeatmapTrackData<IGeneHeatmapTrackDatum, 'hugo_gene_symbol'>(
             'hugo_gene_symbol',
             gene,
             sampleMode ? samples : patients,
             data
         ),
         trackGroupIndex: molecularProfileIdToHeatmapTracks.get(molecularProfileId)!.trackGroupIndex,
         onRemove:action(()=>{
             const trackGroup = molecularProfileIdToHeatmapTracks.get(molecularProfileId);
             if (trackGroup) {
                 trackGroup.genes.delete(gene);
                 if (!trackGroup.genes.size) {
                     molecularProfileIdToHeatmapTracks.delete(molecularProfileId);
                 }
             }
             if (!molecularProfileIdToHeatmapTracks.has(molecularProfileId)
                 && oncoprint.sortMode.type === "heatmap"
                 && oncoprint.sortMode.clusteredHeatmapProfile === molecularProfileId
             ) {
                 oncoprint.sortByData();
             }
         })
     };
 });
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:34,代碼來源:OncoprintUtils.ts

示例4: makeGenesetHeatmapUnexpandHandler

function makeGenesetHeatmapUnexpandHandler(
    oncoprint: ResultsViewOncoprint,
    parentKey: string,
    expansionEntrezGeneId: number,
    myTrackGroup: number,
    onRemoveLast: () => void
) {
    return action('genesetHeatmapUnexpansion', () => {
        const list = oncoprint.expansionsByGenesetHeatmapTrackKey.get(parentKey);
        if (list) {
            // only remove if the expansion if it isn't needed in another track
            // group than the one this track is being removed from; keep the
            // expansion if the track is being re-rendered into a different
            // track group
            if (myTrackGroup === oncoprint.genesetHeatmapTrackGroup) {
                // this is a MobX Observable Array, so it should have findIndex
                // implemented even in IE
                const indexToRemove = list.findIndex(
                    ({entrezGeneId}) => entrezGeneId === expansionEntrezGeneId
                );
                if (indexToRemove !== -1) {
                    list.splice(indexToRemove, 1);
                    if (!list.length) {
                        onRemoveLast();
                    }
                }
            }
        } else {
            throw new Error(`Track '${parentKey}' has no expansions to remove.`);
        }
    });
}
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:32,代碼來源:OncoprintUtils.ts

示例5: dismiss

  @action('dismiss message')
  dismiss() {
    if (this.dismissCancel) {
      this.dismissCancel();
    }

    this.store.remove(this);
  }
開發者ID:Xristinaaaa,項目名稱:Telerik2016,代碼行數:8,代碼來源:Message.ts

示例6: function

    browserWindow.on("closed", function() {
        action(() =>
            windows.splice(windows.findIndex(win => win.browserWindow === browserWindow), 1)
        )();

        // if no visible window left, app can quit
        if (!windows.find(window => window.browserWindow.isVisible())) {
            app.quit();
        }
    });
開發者ID:eez-open,項目名稱:studio,代碼行數:10,代碼來源:window.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: function

ipcMain.on("setMruFilePath", function(event: any, mruItemFilePath: string) {
    action(() => {
        var i = findMruIndex(mruItemFilePath);
        if (i != -1) {
            settings.mru.splice(i, 1);
        }

        settings.mru.unshift({
            filePath: mruItemFilePath
        });
    })();
});
開發者ID:eez-open,項目名稱:studio,代碼行數:12,代碼來源:settings.ts

示例9: function

 function() {
     if (!resizeTimeout) {
         resizeTimeout = setTimeout(
             action(function() {
                 resizeTimeout = undefined;
                 windowSize.width = window.innerWidth;
                 windowSize.height = window.innerHeight;
             }),
             10
         );
     }
 },
開發者ID:eez-open,項目名稱:studio,代碼行數:12,代碼來源:window-size.ts

示例10: dispatch

export default function dispatch(
    action: ActionFunction,
    actionType: string,
    args: IArguments,
    actionContext: ActionContext
): void {
    getGlobalContext().legacyInDispatch++;

    mobxAction(actionType ? actionType : '(anonymous action)', () => {
        dispatchWithMiddleware(action, actionType, args, actionContext);
    })();

    getGlobalContext().legacyInDispatch--;
}
開發者ID:Microsoft,項目名稱:satcheljs,代碼行數:14,代碼來源:dispatch.ts

示例11: updateState

    function updateState() {
        var windowBounds = window.getBounds();

        if (!window.isMaximized() && !window.isMinimized() && !window.isFullScreen()) {
            normalWindowBounds = Object.assign({}, windowBounds);
        }

        var displayBounds = screen.getDisplayMatching(windowBounds).bounds;

        action(() => {
            settings.windowStates[windowId] = {
                bounds: normalWindowBounds,
                isMaximized: window.isMaximized(),
                isFullScreen: window.isFullScreen(),
                displayBounds: Object.assign({}, displayBounds)
            };
        })();
    }
開發者ID:eez-open,項目名稱:studio,代碼行數:18,代碼來源:settings.ts

示例12: loadSettings

export function loadSettings() {
    action(() => {
        settings.mru = [];
        settings.windowStates = {};

        try {
            let data = fs.readFileSync(getSettingsFilePath(), "utf8");

            try {
                let settingsJs: Settings = JSON.parse(data);

                if (settingsJs.mru) {
                    settings.mru = settingsJs.mru.filter((mruItem: IMruItem) =>
                        fs.existsSync(mruItem.filePath)
                    );
                } else {
                    settings.mru = [];
                }

                if (settingsJs.windowStates) {
                    settings.windowStates = settingsJs.windowStates;
                } else {
                    settings.windowStates = {};
                }

                settings.dbPath = settingsJs.dbPath;
                settings.locale = settingsJs.locale;
                settings.dateFormat = settingsJs.dateFormat;
                settings.timeFormat = settingsJs.timeFormat;
            } catch (parseError) {
                console.log(data);
                console.error(parseError);
            }
        } catch (readFileError) {
            console.info(`Settings file "${getSettingsFilePath()}" doesn't exists.`);
        }
    })();
}
開發者ID:eez-open,項目名稱:studio,代碼行數:38,代碼來源:settings.ts

示例13: replace

 @action('replace message')
 replace(text: string, options?: IMessageOptions) {
   this.store.remove(this);
   this.store.add(text, options);
 }
開發者ID:Xristinaaaa,項目名稱:Telerik2016,代碼行數:5,代碼來源:Message.ts

示例14: it

it('date-value round to full day unformated formatDate', () => {
  const n = new DateValue(new Date('2018-07-04 17:01:02'), 'what');
  action(() => n.formatDate.set('2018-09-04 17:01:03'))();
  expect(n.date.get()).toEqual(new Date('2018-09-04'));
  expect(n.formatDate.get()).toEqual(format_date(new Date('2018-09-04')));
});
開發者ID:mabels,項目名稱:clavator,代碼行數:6,代碼來源:date-value.test.ts

示例15: action

    }
    return {
        hasBinary,
        tiers: Object.keys(tiersMap)
    };
}

export const initializeCustomDriverAnnotationSettings = action((
    report:CustomDriverAnnotationReport,
    mutationAnnotationSettings:any,
    enableCustomTiers:boolean,
    enableOncoKbAndHotspotsIfNoCustomAnnotations:boolean
)=>{
    // initialize keys with all available tiers
    for (const tier of report.tiers) {
        mutationAnnotationSettings.driverTiers.set(tier, enableCustomTiers);
    }

    if (enableOncoKbAndHotspotsIfNoCustomAnnotations && !report.hasBinary && !report.tiers.length) {
        // enable hotspots and oncokb if there are no custom annotations
        mutationAnnotationSettings.hotspots = true;
        mutationAnnotationSettings.oncoKb = true;
    }
});

export function annotateMutationPutativeDriver(
    mutation: Mutation,
    putativeDriverInfo:{oncoKb:string, hotspots:boolean, cbioportalCount:boolean, cosmicCount:boolean, customDriverBinary:boolean, customDriverTier?:string},
):AnnotatedMutation {
    const putativeDriver =
        !!(putativeDriverInfo.oncoKb ||
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:31,代碼來源:ResultsViewPageStoreUtils.ts


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