当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript effects.select函数代码示例

本文整理汇总了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));
	}
}
开发者ID:3drepo,项目名称:3drepo.io,代码行数:24,代码来源:groups.sagas.ts

示例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))
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:15,代码来源:workspace.ts

示例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));
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:15,代码来源:workspace.ts

示例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));
  }
}
开发者ID:rosendi,项目名称:figure,代码行数:15,代码来源:forms.ts

示例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));
	}
}
开发者ID:3drepo,项目名称:3drepo.io,代码行数:15,代码来源:groups.sagas.ts

示例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));
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:48,代码来源:dev-server.ts

示例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());
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:16,代码来源:workspace.ts

示例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());
      }
    }
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:16,代码来源:workspace.ts

示例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));
	}
}
开发者ID:3drepo,项目名称:3drepo.io,代码行数:16,代码来源:userManagement.sagas.ts

示例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)); // 刷新特定文章
	}
}
开发者ID:weiweiwitch,项目名称:third-lab,代码行数:16,代码来源:posts.ts


注:本文中的redux-saga/effects.select函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。