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


TypeScript mobx.Reaction類代碼示例

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


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

示例1: function

	target.componentWillMount = function() {

		// Call original
		baseWillMount && baseWillMount.call(this);

		let reaction: Reaction;
		let isRenderingPending = false;

		const initialName = this.displayName || this.name || (this.constructor && (this.constructor.displayName || this.constructor.name)) || '<component>';
		const baseRender = this.render.bind(this);

		const initialRender = (nextProps, nextContext) => {
			reaction = new Reaction(`${initialName}.render()`, () => {
				if (!isRenderingPending) {
					isRenderingPending = true;
					if (this.__$mobxIsUnmounted !== true) {
						let hasError = true;
						try {
							Component.prototype.forceUpdate.call(this);
							hasError = false;
						} finally {
							if (hasError) {
								reaction.dispose();
							}
						}
					}
				}
			});
			reactiveRender.$mobx = reaction;
			this.render = reactiveRender;
			return reactiveRender(nextProps, nextContext);
		};

		const reactiveRender: IReactiveRender = (nextProps, nextContext) => {
			isRenderingPending = false;
			let rendering = undefined;
			reaction.track(() => {
				if (isDevtoolsEnabled) {
					this.__$mobRenderStart = Date.now();
				}
				rendering = extras.allowStateChanges(false, baseRender.bind(this, nextProps, nextContext));
				if (isDevtoolsEnabled) {
					this.__$mobRenderEnd = Date.now();
				}
			});
			return rendering;
		};

		this.render = initialRender;
	};
開發者ID:Keats,項目名稱:inferno,代碼行數:50,代碼來源:makeReactive.ts

示例2: Reaction

			reaction = new Reaction(`${initialName}.render()`, () => {
				if (!isRenderingPending) {
					isRenderingPending = true;
					if (this.__$mobxIsUnmounted !== true) {
						let hasError = true;
						try {
							Component.prototype.forceUpdate.call(this);
							hasError = false;
						} finally {
							if (hasError) {
								reaction.dispose();
							}
						}
					}
				}
			});
開發者ID:Keats,項目名稱:inferno,代碼行數:16,代碼來源:makeReactive.ts

示例3:

b.init(() => {
    var res: b.IBobrilChildren;
    reaction.track(() => {
        res = counter.get();
    });
    return res;
});
開發者ID:Bobris,項目名稱:Bobril,代碼行數:7,代碼來源:app.ts

示例4:

		const reactiveRender: IReactiveRender = (nextProps, nextContext) => {
			isRenderingPending = false;
			let rendering = undefined;
			reaction.track(() => {
				if (isDevtoolsEnabled) {
					this.__$mobRenderStart = Date.now();
				}
				rendering = extras.allowStateChanges(false, baseRender.bind(this, nextProps, nextContext));
				if (isDevtoolsEnabled) {
					this.__$mobRenderEnd = Date.now();
				}
			});
			return rendering;
		};
開發者ID:Keats,項目名稱:inferno,代碼行數:14,代碼來源:makeReactive.ts


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