cycle-gear
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.3
@@ -1,2 +0,2 @@ | ||
import { Stream } from 'xstream'; | ||
import { Observable } from 'xstream'; | ||
export interface GearView<TModel> { | ||
@@ -13,8 +13,8 @@ (model: TModel): any; | ||
export interface Gear<TActions, TModel> { | ||
catch?: (error: any, actions: TActions) => Stream<any>; | ||
catch?: (error: any, actions: TActions) => Observable<any>; | ||
intent?: (sources: any) => TActions; | ||
model?: (actions: TActions) => Stream<TModel>; | ||
model?: (actions: TActions) => Observable<TModel>; | ||
teeth?: GearTeeth<TModel>; | ||
} | ||
export declare type Transmission = ((sources: any) => Stream<Gear<any, any>>) | Stream<Gear<any, any>>; | ||
export declare type Transmission = ((sources: any) => Observable<Gear<any, any>>) | Observable<Gear<any, any>>; | ||
export interface PedalOptions { | ||
@@ -21,0 +21,0 @@ defaultGear?: Gear<any, any>; |
@@ -50,6 +50,7 @@ import { adapt } from '@cycle/run/lib/adapt'; | ||
} | ||
const spin = gear.map(gear => { | ||
const spin = xs.fromObservable(gear) | ||
.map(gear => { | ||
const actions = gear.intent ? gear.intent(sources) : defaultIntent(sources); | ||
const state = (gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError((err) => gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions)) | ||
const state = xs.fromObservable(gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError((err) => xs.fromObservable(gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions))) | ||
.remember(); | ||
@@ -56,0 +57,0 @@ const views = teeth.reduce((accum, tooth) => Object.assign(accum, { |
@@ -1,2 +0,2 @@ | ||
import { Stream } from 'xstream'; | ||
import { Observable } from 'xstream'; | ||
export interface GearView<TModel> { | ||
@@ -13,8 +13,8 @@ (model: TModel): any; | ||
export interface Gear<TActions, TModel> { | ||
catch?: (error: any, actions: TActions) => Stream<any>; | ||
catch?: (error: any, actions: TActions) => Observable<any>; | ||
intent?: (sources: any) => TActions; | ||
model?: (actions: TActions) => Stream<TModel>; | ||
model?: (actions: TActions) => Observable<TModel>; | ||
teeth?: GearTeeth<TModel>; | ||
} | ||
export declare type Transmission = ((sources: any) => Stream<Gear<any, any>>) | Stream<Gear<any, any>>; | ||
export declare type Transmission = ((sources: any) => Observable<Gear<any, any>>) | Observable<Gear<any, any>>; | ||
export interface PedalOptions { | ||
@@ -21,0 +21,0 @@ defaultGear?: Gear<any, any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var adapt_1 = require("@cycle/run/lib/adapt"); | ||
@@ -56,6 +57,7 @@ var xstream_1 = require("xstream"); | ||
} | ||
var spin = gear.map(function (gear) { | ||
var spin = xstream_1.default.fromObservable(gear) | ||
.map(function (gear) { | ||
var actions = gear.intent ? gear.intent(sources) : defaultIntent(sources); | ||
var state = (gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError(function (err) { return gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions); }) | ||
var state = xstream_1.default.fromObservable(gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError(function (err) { return xstream_1.default.fromObservable(gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions)); }) | ||
.remember(); | ||
@@ -62,0 +64,0 @@ var views = teeth.reduce(function (accum, tooth) { |
33
index.ts
import { adapt } from '@cycle/run/lib/adapt' | ||
import xs, { Stream } from 'xstream' | ||
import xs, { Stream, Observable } from 'xstream' | ||
@@ -18,9 +18,9 @@ export interface GearView<TModel> { | ||
export interface Gear<TActions, TModel> { | ||
catch?: (error: any, actions: TActions) => Stream<any> | ||
catch?: (error: any, actions: TActions) => Observable<any> | ||
intent?: (sources: any) => TActions | ||
model?: (actions: TActions) => Stream<TModel> | ||
model?: (actions: TActions) => Observable<TModel> | ||
teeth?: GearTeeth<TModel> | ||
} | ||
export type Transmission = ((sources: any) => Stream<Gear<any, any>>) | Stream<Gear<any, any>> | ||
export type Transmission = ((sources: any) => Observable<Gear<any, any>>) | Observable<Gear<any, any>> | ||
@@ -77,3 +77,3 @@ export interface PedalOptions { | ||
return (sources: any) => { | ||
let gear: Stream<Gear<any, any>> | ||
let gear: Observable<Gear<any, any>> | ||
if (transmission instanceof Function) { | ||
@@ -85,14 +85,15 @@ gear = transmission(sources) | ||
const spin = gear.map(gear => { | ||
const actions = gear.intent ? gear.intent(sources) : defaultIntent(sources) | ||
const state = (gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError((err: any) => gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions)) | ||
.remember() | ||
const views = teeth.reduce((accum, tooth) => Object.assign(accum, { | ||
[tooth]: state.filter(toothFilter(tooth, gear.teeth[tooth])).map(toothView(tooth, gear.teeth[tooth])) | ||
}), | ||
{}) | ||
const spin = xs.fromObservable<Gear<any, any>>(gear) | ||
.map(gear => { | ||
const actions = gear.intent ? gear.intent(sources) : defaultIntent(sources) | ||
const state = xs.fromObservable(gear.model ? gear.model(actions) : defaultModel(actions)) | ||
.replaceError((err: any) => xs.fromObservable(gear.catch ? gear.catch(err, actions) : defaultCatch(err, actions))) | ||
.remember() | ||
const views = teeth.reduce((accum, tooth) => Object.assign(accum, { | ||
[tooth]: state.filter(toothFilter(tooth, gear.teeth[tooth])).map(toothView(tooth, gear.teeth[tooth])) | ||
}), | ||
{}) | ||
return views | ||
}) | ||
return views | ||
}) | ||
.startWith(emptyTeeth) | ||
@@ -99,0 +100,0 @@ .remember() |
{ | ||
"name": "cycle-gear", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.3", | ||
"description": "Main function factory for CycleJS", | ||
@@ -23,3 +23,3 @@ "main": "dist/index.js", | ||
"compile": "tsc -p tsconfig.es2015.json && tsc -p tsconfig.json", | ||
"prepublish": "npm run compile" | ||
"version": "npm run compile" | ||
}, | ||
@@ -39,3 +39,7 @@ "repository": { | ||
"typescript": "^2.1.5" | ||
}, | ||
"dependencies": { | ||
"@cycle/run": "^3.1.0", | ||
"xstream": "^10.6.0" | ||
} | ||
} |
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
48472
347
2
+ Added@cycle/run@^3.1.0
+ Addedxstream@^10.6.0
+ Added@cycle/run@3.4.0(transitive)
+ Addedsymbol-observable@1.2.0(transitive)
+ Addedxstream@10.9.0(transitive)