Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cycle-vtree-switcher

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cycle-vtree-switcher - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

8

lib/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc