本文整理汇总了TypeScript中mobx.action函数的典型用法代码示例。如果您正苦于以下问题:TypeScript action函数的具体用法?TypeScript action怎么用?TypeScript action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了action函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: action
return Object.keys(actions).reduce((newActions: any, key: string) => {
newActions[key] = action(key, (actions as any)[key]);
return newActions;
}, {});
开发者ID:clebert,项目名称:mobx-example,代码行数:4,代码来源:createActions.ts
示例17: setContent
@bind
@action('node.setContent')
public setContent(content = '') {
this.content = content;
}
开发者ID:luketurner,项目名称:scripsi,代码行数:5,代码来源:node.ts
示例18: toggleCollapsed
@bind
@action('node.toggleCollapsed')
public toggleCollapsed() {
this.collapsed = !this.collapsed;
}
开发者ID:luketurner,项目名称:scripsi,代码行数:5,代码来源:node.ts
示例19: setType
@bind
@action('node.setType')
public setType(nodeType: NodeType): SNode {
this.type = nodeType;
return this;
}
开发者ID:luketurner,项目名称:scripsi,代码行数:6,代码来源:node.ts
示例20: runMiddleWares
function runMiddleWares(node: ObjectNode, baseCall: IMiddlewareEvent, originalFn: Function): any {
const handlers = collectMiddlewareHandlers(node, baseCall, originalFn)
// Short circuit
if (!handlers.length) return mobxAction(originalFn).apply(null, baseCall.args)
let index = 0
function runNextMiddleware(call: IMiddlewareEvent): any {
const handler = handlers[index++]
if (handler) return handler(call, runNextMiddleware)
else return mobxAction(originalFn).apply(null, baseCall.args)
}
return runNextMiddleware(baseCall)
}
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:13,代码来源:action.ts
注:本文中的mobx.action函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论