How to use subx - 3 common examples

To help you get started, we’ve selected a few subx 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 electerm / electerm / src / client / store / index.js View on Github external
})

Subx.autoRun(store, () => {
  ls.set('sessions', copy(store.tabs).map(t => {
    delete t.isTransporting
    return t
  }))
  return store.tabs
})

Subx.autoRun(store, () => {
  ls.set('bookmarks', store.bookmarks)
  return store.bookmarks
})

Subx.autoRun(store, () => {
  const themesObj = store.themes.reduce((p, k) => {
    return {
      ...p,
      [k.id]: k
    }
  }, {})
  ls.set('themes', themesObj)
  return store.themes
})

Subx.autoRun(store, () => {
  ls.set('quickCommands', store.quickCommands)
  return store.quickCommands
})

Subx.autoRun(store, () => {
github electerm / electerm / src / client / store / index.js View on Github external
} else if (tab === settingMap.quickCommands) {
    return {
      id: '',
      name: q(newQuickCommand)
    }
  }
}

const tabs = [newTerm()]
const bookmarks = copy(ls.get(settingMap.bookmarks) || [])
const bookmarkGroups = copy(
  ls.get(settingMap.bookmarkGroups) ||
  getDefaultBookmarkGroups(bookmarks)
)

const store = Subx.create({
  tabs,
  height: 500,
  width: window.innerWidth - sidebarWidth,
  currentTabId: tabs[0].id,
  history: copy(ls.get(settingMap.history) || []),
  quickCommands: copy(ls.get(settingMap.quickCommands) || []),
  quickCommandId: '',
  bookmarks,
  bookmarkGroups,
  setting: [
    {
      id: 'setting-sync',
      title: ss('settingSync')
    }
  ],
  sshConfigItems: copy(getGlobal('sshConfigItems')),
github electerm / electerm / src / client / components / common / react-subx.jsx View on Github external
this.render = () => {
      clearSubscription()
      const { result, stream$ } = SubX.runAndMonitor(props.store, render)
      this.__subscription__ = stream$.subscribe(event => {
        if (event.type === 'STALE' && R.equals(R.path(event.path, props.store), event.cache)) {
          return
        }
        clearSubscription()
        this.forceUpdate()
      })
      return result
    }
    if (this.componentWillUnmount) {

subx

SubX, Next generation state container

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis