How to use the mobx-state-tree.getSnapshot function in mobx-state-tree

To help you get started, we’ve selected a few mobx-state-tree 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 zeit / next.js / examples / with-mobx-state-tree-typescript / pages / _app.tsx View on Github external
//
    // Use getInitialProps as a step in the lifecycle when
    // we can initialize our store
    //
    const isServer = typeof window === 'undefined'
    const store = initializeStore(isServer)
    //
    // Check whether the page being rendered by the App has a
    // static getInitialProps method and if so call it
    //
    let pageProps = {}
    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx)
    }
    return {
      initialState: getSnapshot(store),
      isServer,
      pageProps,
    }
  }
github mobxjs / mobx-state-tree / packages / mst-example-boxes / src / stores / domain-state.spec.js View on Github external
test("it should be able to move boxes - 1", () => {
    var box = Box.create({ x: 100, y: 100, id: "1", name: "test" })

    box.move(23, 10)
    expect(getSnapshot(box)).toMatchSnapshot()

    box.move(22, -13)
    expect(getSnapshot(box)).toMatchSnapshot()
})
github enlyth / GradientLab / src / Components / NavButtons.jsx View on Github external
onPointerUp={() => {
          try {
            window.localStorage.setItem(
              '__GRADIENTLAB_STORE__',
              JSON.stringify(getSnapshot(store))
            )
          } catch (err) {
            console.error(err)
          }

          toast('Saved', {
            position: 'bottom-right'
          })
        }}
      >
github Feverqwe / tSearch / srcDraft / js / models / historyModel.js View on Github external
const handleHistoryChangeListener = (changes, namespace) => {
    if (namespace === 'local') {
      const change = changes.history;
      if (change) {
        const history = change.newValue;
        if (!_isEqual(history, getSnapshot(self.history))) {
          self.assign({history});
        }
      }
    }
  };
github infinitered / reactotron / packages / reactotron-mst / src / reactotron-mst.ts View on Github external
function requestValues(command: any) {
      const trackedNode = trackedNodes[command.mstNodeName || "default"]
      const atPath: string = (command && command.payload && command.payload.path) || []
      if (trackedNode && trackedNode.node && atPath) {
        const state = getSnapshot(trackedNode.node)
        if (isNilOrEmpty(atPath)) {
          reactotron.stateValuesResponse(null, state)
        } else {
          reactotron.stateValuesResponse(atPath, dotPath(atPath, state))
        }
      }
    }
github skellock / mst-async-storage / src / with-async-storage.ts View on Github external
save: flow(function*() {
        yield save(key, filterSnapshotKeys(getSnapshot(self)))
      }),
github grafana / grafana / public / app / containers / ManageDashboards / FolderSettings.tsx View on Github external
return folder.load(view.routeParams.get('uid') as string).then(res => {
      this.formSnapshot = getSnapshot(folder);
      this.dashboard = res.dashboard;

      view.updatePathAndQuery(`${res.meta.url}/settings`, {}, {});

      return nav.initFolderNav(toJS(folder.folder), 'manage-folder-settings');
    });
  }
github jsdevkr / gitCodeShare.com / pages / _app.js View on Github external
static async getInitialProps({ Component, router, ctx }) {
    let pageProps = {};

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx);
    }

    return { pageProps, initialState: getSnapshot(appStoreInstance.get()) };
  }
github Feverqwe / tSearch / srcDraft / js / components / Explore / exploreModel.js View on Github external
return limitOne(() => {
        const sections = getSnapshot(self.sections);
        return promisifyApi('chrome.storage.local.set')({explorerSections: sections});
      });
    },