cycle-vtree-switcher
Advanced tools
Comparing version 0.0.1 to 1.0.0
@@ -11,6 +11,10 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | ||
var _cycleCore = require('@cycle/core'); | ||
var _rx = require('rx'); | ||
var _rx2 = _interopRequireDefault(_rx); | ||
var _cycleRoute = require('cycle-route'); | ||
@@ -51,3 +55,3 @@ | ||
}); | ||
var vtree$ = (_Rx$Observable = _cycleCore.Rx.Observable).combineLatest.apply(_Rx$Observable, [Route].concat(_toConsumableArray(vtree$s), [function (route) { | ||
var vtree$ = (_Rx$Observable = _rx2['default'].Observable).combineLatest.apply(_Rx$Observable, [Route].concat(_toConsumableArray(vtree$s), [function (route) { | ||
for (var _len = arguments.length, vtrees = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
@@ -54,0 +58,0 @@ vtrees[_key - 1] = arguments[_key]; |
{ | ||
"name": "cycle-vtree-switcher", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "A Cycle.js helper for switching between route handlers", | ||
@@ -32,3 +32,3 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"@cycle/core": "^4.0.0" | ||
"rx": "^4.0.6" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
@@ -17,4 +17,4 @@ # Cycle VTree Switcher | ||
* ```routes```: an object mapping from ```routington``` route definitions to route handlers which are functions like Cycle.js main functions: ```main(responses: Object) -> requests: Object``` | ||
* ```responses```: an object containing Cycle.js driver responses/sources. Must include a ```Path``` response, which can be built using [```cycle-pushstate-driver```](https://github.com/secobarbital/cycle-pushstate-driver) | ||
* ```routes```: an object mapping from [routington](https://github.com/pillarjs/routington) route definitions to route handlers which are functions like Cycle.js main functions: ```main(responses: Object) -> requests: Object```. ```cycle-vtree-switcher``` uses [cycle-route](https://github.com/secobarbital/cycle-route) under the hood so it also supports ```*``` as the default route. | ||
* ```responses```: an object containing Cycle.js driver responses/sources. Must include a ```Path``` response, which can be built using [cycle-pushstate-driver](https://github.com/secobarbital/cycle-pushstate-driver). | ||
@@ -26,18 +26,8 @@ Output: | ||
## Usage | ||
## Gotchas | ||
Basics: | ||
* ```Rx.Observable.combineLatest``` is used to combine the route and route handlers, and it will only emit when every source has emitted, so make sure to have each route handler emit a starting vtree. This could be a loading page. | ||
```js | ||
import { makeRouter } from 'cycle-route' | ||
## Usage | ||
const router = makeRouter({ | ||
'/': 'home', | ||
'/foo/:bar': 'foo', | ||
'*': 'notfound' // default route | ||
}) | ||
router('/') | ||
``` | ||
[Cycle.js](http://cycle.js.org/) use case: | ||
@@ -48,3 +38,2 @@ | ||
import { makeDOMDriver } from '@cycle/dom' | ||
import { makeFetchDriver } from ‘@cycle/fetch’ | ||
import { makePushStateDriver } from 'cycle-pushstate-driver' | ||
@@ -66,3 +55,3 @@ import vtreeSwitcher from 'cycle-vtree-switcher' | ||
function main (responses) { | ||
const { DOM, Fetch, Path } = responses | ||
const { DOM, Path } = responses | ||
@@ -82,1 +71,5 @@ const [vtree$, requestMap] = vtreeSwitcher(routes, responses) | ||
``` | ||
## Full Example | ||
[iouo.me](https://github.com/secobarbital/iouo.me/blob/ba6608179a7bc69e81c378b2639014de7f9c1f26/src/index.js) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5387
47
0
71