本文整理汇总了TypeScript中redux-saga/effects.spawn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript spawn函数的具体用法?TypeScript spawn怎么用?TypeScript spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: handleDevConfigLoaded
function* handleDevConfigLoaded() {
const {
rootPath,
context
}: ExtensionState = yield select();
const config = workspace.getConfiguration("tandem.paperclip");
const childServerPort = yield call(getPort);
console.log(`spawning Paperclip dev server with env PORT ${childServerPort}`);
console.log(JSON.stringify(config.devServer));
let proc;
const chan = eventChannel(emit => {
proc = startPCDevServer({
cwd: rootPath,
pipeStdio: true,
projectConfig: config.devServer,
port: childServerPort
}, emit);
return () => {
proc.dispose();
};
});
yield spawn(function*() {
while(1) {
const action = yield take(chan);
action[TAG] = 1;
yield spawn(function*() {
yield put(action);
});
}
});
yield spawn(function*() {
while(1) {
const action = yield take();
if (action[TAG] || !action.$public) continue;
proc.send(action);
}
});
yield put(childDevServerStarted(childServerPort));
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:48,代码来源:dev-server.ts
示例2: spawn
yield spawn(function*() {
yield put(artboardLoading(artboardId));
// TODO - if state exists, then fetch diffs diffs instead
const state: ApplicationState = yield select();
const artboard = getArtboardById(artboardId, state);
const [dependencyUris, compressedNode] = yield call(getComponentPreview, artboard.componentId, artboard.previewName, state);
let doc = uncompressRootNode([dependencyUris, compressedNode]);
const checksum = getDocumentChecksum(doc as SlimParentNode);
const idSeed = crc32(checksum + artboard.$id);
doc = setVMObjectIds(doc, idSeed);
const mount = document.createElement("iframe");
mount.setAttribute("style", `border: none; width: 100%; height: 100%`);
const renderChan = eventChannel((emit) => {
mount.addEventListener("load", () => {
emit(renderDOM2(doc, mount.contentDocument.body));
});
return () => {};
});
yield spawn(function*() {
yield put(artboardRendered(artboardId, yield take(renderChan)));
});
// Unique IDs necessary for the front-end to ensure that other artboards with the same component & preview don't contain the same node IDs.
const html: SlimElement = createSlimElement("html", "html", [], [
createSlimElement("body", "body", [], [doc])
]);
yield put(artboardLoaded(artboard.$id, dependencyUris, html, checksum, mount));
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:33,代码来源:artboard.ts
示例3: fork
yield fork(function* handleFileEditRequest() {
while(true) {
const req: ApplyFileMutations = yield take(APPLY_FILE_MUTATIONS);
const { apiHost }: SyntheticBrowserRootState = yield select();
const { mutations } = req;
const state = yield select();
const mutationsByUri: {
[identifier: string]: Mutation<any>[]
} = {};
for (const mutation of mutations) {
const source = (mutation.target as SEnvNodeInterface).source;
if (!mutationsByUri[source.uri]) {
mutationsByUri[source.uri] = [];
}
mutationsByUri[source.uri].push(mutation);
}
const stringMutations: StringMutation[] = [];
yield spawn(function*() {
yield call(apiEditFile, mutationsByUri, yield select());
});
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:26,代码来源:file-editor.ts
示例4: spawn
yield spawn(function*() {
while(true) {
yield spawn(function*() {
yield route(...(yield take(chan)));
});
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:7,代码来源:api.ts
示例5: fork
yield fork(function*() {
let connectingChan;
while(1) {
yield take([OPENING_TANDEM_APP, TANDEM_FE_CONNECTIVITY]);
const state: ExtensionState = yield select();
if (connectingChan) {
yield cancel(connectingChan);
connectingChan = undefined;
}
if (state.tandemEditorStatus === TandemEditorReadyStatus.CONNECTED) {
status.text = "$(zap) Tandem";
status.tooltip = "Connected to Tandem";
} else if (state.tandemEditorStatus === TandemEditorReadyStatus.CONNECTING) {
status.tooltip = "Connecting to Tandem";
connectingChan = yield spawn(function*() {
while(1) {
// https://github.com/sindresorhus/elegant-spinner/blob/master/index.js
status.text = SPIN_SEQ.charAt(i = (i + 1) % SPIN_SEQ.length) + " Tandem";
yield call(delay, 100);
}
});
} else if (state.tandemEditorStatus === TandemEditorReadyStatus.DISCONNECTED) {
status.text = "▶ Tandem";
status.tooltip = "Disconnected from Tandem";
}
status.show();
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:31,代码来源:vscode.ts
示例6: openSyntheticWindowEnvironment
function* openSyntheticWindowEnvironment({ $id: windowId = generateDefaultId(), location, bounds, scrollPosition }: SyntheticWindow, browserId: string) {
let main: SEnvWindowInterface;
const documentId = generateDefaultId();
const fetch = yield getFetch();
const { apiHost }: SyntheticBrowserRootState = yield select();
let currentWindow: SEnvWindowInterface;
const reloadChan = yield eventChannel((emit) => {
const reload = (bounds?: Bounds) => {
if (currentWindow) {
currentWindow.dispose();
}
const SEnvWindow = getSEnvWindowClass({
console: getSEnvWindowConsole(),
fetch,
reload: () => reload(),
getProxyUrl: (url: string) => {
return apiHost && url.substr(0, 5) !== "data:" && url.indexOf(window.location.host) === -1 ? apiHost + "/proxy/" + encodeURIComponent(url) : url;
},
createRenderer: (window: SEnvWindowInterface) => {
return window.top === window ? new SyntheticMirrorRenderer(window) : new SyntheticDOMRenderer(window, document)
}
});
const window = currentWindow = new SEnvWindow(location, browserId);
// ick. Better to use seed function instead to generate UIDs <- TODO.
window.$id = windowId;
window.document.$id = documentId;
if (bounds) {
window.moveTo(bounds.left, bounds.top);
if (bounds.right) {
window.resizeTo(bounds.right - bounds.left, bounds.bottom - bounds.top);
}
}
emit(window);
return window;
};
reload(bounds);
return () => { };
});
yield spawn(function*() {
while(true) {
yield watchWindowExternalResourceUris(currentWindow, () => currentWindow.location.reload());
currentWindow.$load();
const isNew = !getSyntheticWindow(yield select(), currentWindow.$id);
yield put(syntheticWindowOpened(currentWindow, null, isNew));
yield take(reloadChan);
}
});
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:59,代码来源:synthetic-browser.ts
示例7: fork
yield fork(function*() {
while(true) {
const e = yield take(chan);
yield spawn(function*() {
yield put(e);
})
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:8,代码来源:synthetic-browser.ts
示例8: spawn
yield spawn(function*() {
while(1) {
const action = yield take(chan);
action[TAG] = 1;
yield spawn(function*() {
yield put(action);
});
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:9,代码来源:dev-server.ts
示例9: screenshotsSaga
export function* screenshotsSaga() {
yield spawn(handleTakingScreesnshots);
yield fork(handleNewScreenshot);
yield fork(handleSavedScreenshot);
yield fork(cleanupOldScreenshots);
// last thing to launch
yield fork(openHeadlessBrowser);
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:9,代码来源:screenshots.ts
示例10: handleOpenedSyntheticProxyWindow
function* handleOpenedSyntheticProxyWindow() {
while(true) {
const { instance } = (yield take(SYNTHETIC_WINDOW_PROXY_OPENED)) as SyntheticWindowOpened;
const thread = yield spawn(handleSyntheticWindowInstance, instance);
yield fork(function*() {
yield take((action: Removed) => action.type === REMOVED && action.itemId === instance.$id);
yield cancel(thread);
})
}
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:10,代码来源:synthetic-browser.ts
注:本文中的redux-saga/effects.spawn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论