0.1.3 • Published 9 years ago

@koax/location v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

location

Build status Git tag NPM version Code style

Location effects.

Installation

$ npm install @koax/location

Usage

import {locationEffect, setUrl} from '@koax/location'
import koax, {run} from 'koax'

let state = {}

let io = koax()
io.use(locationEffect(url => {type: 'CHANGE_URL', url}))
io.use(function (action, next) {
  if (action.type === 'CHANGE_URL'){
    state.url = action.url
  }
  return next()
})

let interpret = run(io)

interpret(function * () {
  yield setUrl('/foo')
  state.url // /foo
})

API

locationEffect(listener)

  • listener - listen for location changes

Returns: koax middleware

setUrl(url)

  • url - push url to history

Returns: set url action

License

MIT