How to use the mobx.set function in mobx

To help you get started, we’ve selected a few mobx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github choerodon / iam-service / react / src / app / iam / containers / organization / role / RoleMsg.js View on Github external
handleClickExpandBtn = () => {
    const tabLevel = RoleStore.tabLevel || this.tabLevel;
    const expand = get(RoleStore.expand, tabLevel);
    if (expand) {
      // 需要展开
      set(RoleStore.expandedRowKeys, tabLevel, this.getAllIdByLevel(tabLevel));
    } else {
      // 需要收起
      set(RoleStore.expandedRowKeys, tabLevel, []);
    }
    set(RoleStore.expand, tabLevel, !expand);
  }
github xaviergonz / mobx-keystone / packages / lib / src / snapshot / reconcileSnapshot.ts View on Github external
function reconcileArraySnapshot(value: any, sn: SnapshotInOfArray): any[] {
  if (!isArray(value)) {
    // no reconciliation possible
    return fromSnapshot(sn)
  }

  // remove excess items
  if (value.length > sn.length) {
    value.splice(sn.length, value.length - sn.length)
  }

  // reconcile present items
  for (let i = 0; i < value.length; i++) {
    set(value, i as any, reconcileSnapshot(value[i], sn[i]))
  }

  // add excess items
  for (let i = value.length; i < sn.length; i++) {
    value.push(fromSnapshot(sn[i]))
  }

  return value
}
github xaviergonz / mobx-keystone / packages / lib / src / snapshot / reconcileSnapshot.ts View on Github external
for (let i = 0; i < dataKeysLen; i++) {
    const k = dataKeys[i]
    if (!(k in processedSn)) {
      remove(data, k)
    }
  }

  // reconcile the rest
  const processedSnKeys = Object.keys(processedSn)
  const processedSnKeysLen = processedSnKeys.length
  for (let i = 0; i < processedSnKeysLen; i++) {
    const k = processedSnKeys[i]
    if (!isReservedModelKey(k)) {
      const v = processedSn[k]

      set(data, k, reconcileSnapshot(data[k], v))
    }
  }

  return modelObj
}
github jiangshanmeta / react-admin / src / components / common / editor / _withFieldRelates.js View on Github external
setCacheOptions(options,cacheObj){
            let start = this.optionsCache;
            const len = this.relateKeys.length;
            let counter = 0;
            while(counter
github xaviergonz / mobx-keystone / packages / lib / src / tweaker / tweakArray.ts View on Github external
if (isPrimitive(v)) {
      if (!doNotTweakChildren) {
        set(tweakedArr, i, v)
      }

      standardSn[i] = v
    } else {
      const path = { parent: tweakedArr, path: i }

      let tweakedValue
      if (doNotTweakChildren) {
        tweakedValue = v
        setParent(tweakedValue, path, false, false)
      } else {
        tweakedValue = tweak(v, path)
        set(tweakedArr, i, tweakedValue)
      }

      const valueSn = getInternalSnapshot(tweakedValue)!
      standardSn[i] = valueSn.standard
    }
  }

  setInternalSnapshot(tweakedArr, standardSn)

  interceptDisposer = intercept(tweakedArr, interceptArrayMutation.bind(undefined, tweakedArr))
  observeDisposer = observe(tweakedArr, arrayDidChange)

  return tweakedArr as any
}
github pythonkr / pyconkr-web / lib / stores / Sponsor / SponsorStore.ts View on Github external
setProposal(proposal: any) {
        set(this.proposal, proposal as { [key: string]: any })
        this.isProposalInitialized = proposal !== null
        if (proposal && proposal.level) {
            set(this.proposalLevel, proposal.level as { [key: string]: any})
        }
    }
github pythonkr / pyconkr-web / lib / stores / Schedule / ScheduleStore.ts View on Github external
async retrieveSchedule() {
        const response = await getSchedule(client)({})
        if (response.data.schedule) {
            set(this.schedule, response.data.schedule)
        }
    }
github choerodon / devops-service / react / routes / pipeline / stores / PipelineCreateStore.js View on Github external
@action setTaskList(stage, data) {
    set(this.taskList, { [stage]: [...(this.taskList[stage] || []), data] });
  }
github choerodon / choerodon-front-boot / src / containers / stores / c7n / DashboardStore.js View on Github external
Object.keys(group).forEach((key) => {
      const found = group[key] && group[key].find(
        ({ dashboardCode, dashboardNamespace }) => dashboardCode === code
          && dashboardNamespace === namespace,
      );
      if (found) {
        set(found, 'dashboardTitle', title);
        set(found, 'dashboardName', name);
        set(found, 'dashboardIcon', icon);
      }
    });
  }
github choerodon / devops-service / react / stores / project / pipeline / PipelineCreateStore.js View on Github external
@action editStage(id, data) {
    const stage = _.find(this.stageList, ['tempId', id]);
    set(stage, { ...data });
  }