How to use the @cycle/state.Instances function in @cycle/state

To help you get started, we’ve selected a few @cycle/state 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 sarimarton / powercycle / src / util.js View on Github external
return sources => {
    const _stream = resolveStateMapper(stream, sources)

    const instances$ = _stream.fold(function (acc, next) {
      const key = next && next.key || uniqueId()
      const cmp = getCmp(next)
      const sinks = cmp(sources)

      acc.dict.clear()
      acc.dict.set(key, sinks)

      return { dict: acc.dict, arr: [{ ...sinks, _key: key }] }
    }, { dict: new Map(), arr: [] })

    return collectSinksBasedOnSource(sources)(new Instances(instances$))
  }
}
github sarimarton / powercycle / src / util / Collection.js View on Github external
return cum.concat({ ...acc.dict.get(key), _key: key })
      }, [])

      acc.dict.forEach((_, key) => {
        if (!keys.has(key)) {
          acc.dict.delete(key)
        }
      })

      keys.clear()

      return { dict: acc.dict, arr: nextInstArray }

    }, { dict: new Map(), arr: [] })

    return collectSinksBasedOnSource(sources)(new Instances(instances$))
  }
}

@cycle/state

Wraps your Cycle.js main function with reducer-driven state management

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis