1.7.1 • Published 6 years ago

cycle-state v1.7.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

cycle-state

Tests Stability Dependencies

NOTICE: While this worked on a small scale, I've decided that it doesn't do enough. I've moved development to cycle-channel.

Create a stream of state for your view layer in cycle

Usage

Alright, so you've got a simple Cycle.js application built:

import xstream from "xstream"

function application (state) {
  return p({
    inner: `Hello, world! My nam  e is ${state.author.name}`,
  })
}

function cycle (sources) {
  const state = sources.DOM.events("click")
  const view = state.map(application)

  return {
    DOM: view,
  }
}
const drivers = {
  DOM: makeDOMDriver("body"),
}

run(cycle, drivers)

Here you're mapping click events into a state. Wouldn't it be cool if we could redux this bitch:

const intents = {
  openModal: (state) => (event) => (payload) => {
    return {
      ...state,
      modal: true,
    }
  }
}
const initialState = {
  openModal: false,
}

function cycle (sources) {
  const state = cycleState(
    intents
  )(
    initialState
  )(
    sources.DOM.events("click")
  )
  const view = state.map(application)

  return {
    DOM: view,
  }
}
1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago