本文整理汇总了TypeScript中redux-saga/effects.select函数的典型用法代码示例。如果您正苦于以下问题:TypeScript select函数的具体用法?TypeScript select怎么用?TypeScript select使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setNewGroup
export function* setNewGroup() {
const currentUser = yield select(selectCurrentUser);
const groups = yield select(selectGroups);
const groupNumber = groups.length + 1;
try {
const newGroup = prepareGroup({
author: currentUser.username,
name: `Untitled group ${groupNumber}`,
color: getRandomColor(),
description: '(No description)'
});
yield put(GroupsActions.setComponentState({
showDetails: true,
activeGroup: null,
totalMeshes: 0,
newGroup,
criteriaFieldState: INITIAL_CRITERIA_FIELD_STATE
}));
} catch (error) {
yield put(DialogActions.showErrorDialog('set', 'new group', error));
}
}
示例2: shiftSelectedArtboard
function* shiftSelectedArtboard(indexDelta: number) {
const state: ApplicationState = yield select();
const workspace = getSelectedWorkspace(state);
const artboard = getWorkspaceLastSelectionOwnerArtboard(state, state.selectedWorkspaceId) || workspace.artboards[workspace.artboards.length - 1];
if (!artboard) {
return;
}
const index = workspace.artboards.indexOf(artboard);
const change = index + indexDelta
// TODO - change index based on window location, not index
const newIndex = change < 0 ? workspace.artboards.length - 1 : change >= workspace.artboards.length ? 0 : change;
yield put(artboardSelectionShifted(workspace.artboards[newIndex].$id))
}
示例3: handleComponentsPaneAddClicked
function* handleComponentsPaneAddClicked() {
while(true) {
yield take(COMPONENTS_PANE_ADD_COMPONENT_CLICKED);
const name = prompt("Unique component name");
if (!name) {
continue;
}
const state: ApplicationState = yield select();
const workspace = getWorkspaceById(state, state.selectedWorkspaceId);
const { componentId } = yield call(apiCreateComponent, name, state);
console.error("TODO");
// yield put(openSyntheticWindowRequest({ location: apiGetComponentPreviewURI(componentId, state)}, workspace.browserId));
}
}
示例4: watchIndexRedirect
function* watchIndexRedirect() {
while (true) {
yield take(REDIRECT_TO_FIRST_FORM);
const { forms } = yield select();
if (forms.rows.isEmpty()) {
var redirectTo = 'forms/new';
} else {
var redirectTo = `forms/${forms.rows.get(0).id}`;
}
yield put(routeActions.push(redirectTo));
}
}
示例5: toggleColorOverride
export function* toggleColorOverride({ group, render }) {
try {
const colorOverrides = yield select(selectColorOverrides);
const hasColorOverride = colorOverrides[group._id];
if (!hasColorOverride) {
yield put(GroupsActions.addColorOverride([group]));
} else {
const overridedGroup = colorOverrides[group._id];
yield put(GroupsActions.removeColorOverride([overridedGroup]));
}
} catch (error) {
yield put(DialogActions.showErrorDialog('toggle', 'color override', error));
}
}
示例6: 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));
}
示例7: handleDNDEnded
function* handleDNDEnded() {
while(true) {
const event = yield take(DND_ENDED);
const state: ApplicationState = yield select();
const workspace = getSelectedWorkspace(state);
const dropRef = getStageToolMouseNodeTargetReference(state, event as DNDEvent);
if (dropRef) {
yield call(handleDroppedOnElement, dropRef, event);
} else {
yield call(handleDroppedOnEmptySpace, event);
}
yield put(dndHandled());
}
}
示例8: handleDeleteKeyPressed
function* handleDeleteKeyPressed() {
while(true) {
const action = (yield take(DELETE_SHORCUT_PRESSED)) as DeleteShortcutPressed;
const state = yield select();
const { sourceEvent } = event as DeleteShortcutPressed;
const workspace = getSelectedWorkspace(state);
for (const [type, id] of workspace.selectionRefs) {
yield put(workspaceSelectionDeleted(workspace.$id));
yield put(removed(id, type as any));
if (workspace.stage.fullScreen && workspace.stage.fullScreen.artboardId === id) {
yield put(fullScreenTargetDeleted());
}
}
}
}
示例9: fetchModelsPermissions
export function* fetchModelsPermissions({ models }) {
try {
const teamspace = yield select(selectCurrentTeamspace);
let data = [];
if (models.length) {
const requiredModels = models.map(({ model }) => model);
const response = yield API.fetchModelsPermissions(teamspace, requiredModels);
data = response.data;
}
yield put(UserManagementActions.fetchModelPermissionsSuccess(data));
} catch (error) {
yield put(DialogActions.showEndpointErrorDialog('get', 'models/federations permissions', error));
}
}
示例10: refreshPostsDeal
export function* refreshPostsDeal(): any {
while (true) {
yield race({
login: take(LOGIN_SUCCESS),
addPost: take(ADD_WIKI_SPECPOST_SUCCESS),
change: take(CHG_WIKI_SPECPOST_SUCCESS),
delPost: take(DEL_WIKI_SPECPOST_SUCCESS),
});
// 触发查询
yield put(queryPosts()); // 刷新文章
const specTagId = yield select(getSpecTagId);
yield put(querySpecTagPosts(specTagId)); // 刷新特定文章
}
}