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


TypeScript object-path.get函数代码示例

本文整理汇总了TypeScript中object-path.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: storageGet

export function storageGet(key: string, paths: string[], defaultValue: any = null): any {
    if (paths.length === 0)
        throwError( "storageSet(): paths.length===0 для key='" + key + "'");
    if (paths.length > 3)
        throwError( "storageSet(): paths.length>3 для key='" + key + "'");


    for (let i = 0; i < 2; i++) {
        let fullKey = "<user>:" + key;
        if (i === 0)
            fullKey = appState.userId + ":" + key;

        let objStr = localStorage.getItem(fullKey);

        if (objStr) {
            let obj = XJSON_parse(objStr);
            if (paths[2]) {
                let value = objectPath.get(obj, paths[0] + "." + paths[1] + "." + paths[2], null);
                if (value) return value;
            }
            if (paths[1]) {
                let value = objectPath.get(obj, paths[0] + "." + paths[1], null);
                if (value) return value;
            }
            let value = objectPath.get(obj, paths[0], null);
            if (value) return value;

        }
    }

    return defaultValue;
}
开发者ID:KostiaSA,项目名称:BuhtaClient2019,代码行数:32,代码来源:storageGet.ts

示例2: mergeMap

    mergeMap(({ payload: { serverId, kernelName } }) => {
      const configPath = [
        "entities",
        "serversById",
        serverId,
        "server",
        "config"
      ];
      const config = objectPath.get(state$.value, configPath);
      return kernels.start(config, kernelName, "").pipe(
        mergeMap(data => {
          const session = uuid();
          const kernel = Object.assign({}, data.response, {
            channel: kernels.connect(
              config,
              data.response.id,
              session
            )
          });

          kernel.channel.next(kernelInfoRequest());

          return merge(
            of(
              actions.activateKernelFulfilled({
                serverId,
                kernelName,
                kernel
              })
            )
          );
        })
      );
    })
开发者ID:nteract,项目名称:play,代码行数:34,代码来源:epics.ts

示例3: formReducer

export default function formReducer(state = {}, action: any): FormState {
  switch (action.type) {
    case VALUE:
      return immutable.set(state, action.payload.path, action.payload.value)

    case VALIDATION_ERROR:
      // if error already exists at path, dont overwrite it
      return objectPath.get(state, ['errors', action.payload.path])
        ? state
        : immutable.set(state, ['errors', action.payload.path], action.payload.error)

    case CLEAR_VALIDATION_ERROR:
      const newState = immutable.del(state, ['errors', action.payload.path])

      // delete errors key from state if empty array
      if (newState.errors && Object.keys(newState.errors).length === 0) {
        delete newState.errors
      }

      return newState

    case SET_STATE:
      return { ...state, ...action.payload }

    case INIT_STATE:
      return action.payload

    default:
      return state
  }
}
开发者ID:jschr,项目名称:react-redux-local-form,代码行数:31,代码来源:formReducer.ts

示例4: runValidator

    async function runValidator(validator: Validator): Promise<boolean> {
      const formState = getFormState()
      const value = objectPath.get(formState, validator.path)

      try {
        await validator.fn(value, formState, validator.path)
        dispatch(actions.clearValidationError(validator.path))
        return true
      } catch (err) {
        dispatch(actions.setValidationError(validator.path, err))
        return false
      }
    }
开发者ID:jschr,项目名称:react-redux-local-form,代码行数:13,代码来源:formEnhancer.ts

示例5: objectPathGet

export function objectPathGet(object: any, propPath: string, defaultValue?: any): any {
    return objectPath.get(object, propPath, defaultValue);
}
开发者ID:KostiaSA,项目名称:BuhtaClient2019,代码行数:3,代码来源:objectPathGet.ts

示例6:

 getKey: action => objectPath.get(action, "payload.serverId"),
开发者ID:nteract,项目名称:play,代码行数:1,代码来源:reducer.ts


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