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

refract-xstream

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refract-xstream - npm Package Compare versions

Comparing version 1.0.0-6 to 1.0.0-7

24

index.es.js

@@ -60,4 +60,9 @@ import xs from 'xstream';

props: {},
fnProps: {}
fnProps: {},
event: {}
};
_this.pushEvent = function (eventName) { return function (val) {
var listeners = _this.listeners.event[eventName] || [];
listeners.forEach(function (listener) { return listener.next(val); });
}; };
Object.keys(props).forEach(function (propName) {

@@ -100,8 +105,15 @@ var prop = props[propName];

};
var createSignalObservable = function (eventName) {
return createObservable(function (listener) {
_this.listeners.event[eventName] = (_this.listeners.event[eventName] || []).concat(listener);
return function () {
_this.listeners.event[eventName].filter(function (l) { return l !== listener; });
};
});
};
_this.component = {
mount: mountObservable,
unmount: unmountObservable,
observe: function (propName) {
return createPropObservable(propName);
}
observe: createPropObservable,
event: createSignalObservable
};

@@ -134,3 +146,5 @@ var sinkObservable = aperture(_this.props)(_this.component);

WithEffects.prototype.render = function () {
return createElement(BaseComponent, Object.assign({}, this.props, this.decoratedProps));
return createElement(BaseComponent, Object.assign({}, this.props, this.decoratedProps, {
pushEvent: this.pushEvent
}));
};

@@ -137,0 +151,0 @@ WithEffects.prototype.sendNext = function (prevProps) {

@@ -66,4 +66,9 @@ 'use strict';

props: {},
fnProps: {}
fnProps: {},
event: {}
};
_this.pushEvent = function (eventName) { return function (val) {
var listeners = _this.listeners.event[eventName] || [];
listeners.forEach(function (listener) { return listener.next(val); });
}; };
Object.keys(props).forEach(function (propName) {

@@ -106,8 +111,15 @@ var prop = props[propName];

};
var createSignalObservable = function (eventName) {
return createObservable(function (listener) {
_this.listeners.event[eventName] = (_this.listeners.event[eventName] || []).concat(listener);
return function () {
_this.listeners.event[eventName].filter(function (l) { return l !== listener; });
};
});
};
_this.component = {
mount: mountObservable,
unmount: unmountObservable,
observe: function (propName) {
return createPropObservable(propName);
}
observe: createPropObservable,
event: createSignalObservable
};

@@ -140,3 +152,5 @@ var sinkObservable = aperture(_this.props)(_this.component);

WithEffects.prototype.render = function () {
return React.createElement(BaseComponent, Object.assign({}, this.props, this.decoratedProps));
return React.createElement(BaseComponent, Object.assign({}, this.props, this.decoratedProps, {
pushEvent: this.pushEvent
}));
};

@@ -143,0 +157,0 @@ WithEffects.prototype.sendNext = function (prevProps) {

{
"name": "refract-xstream",
"version": "1.0.0-6",
"version": "1.0.0-7",
"main": "index.js",

@@ -5,0 +5,0 @@ "jsnext:main": "index.es.js",

@@ -67,3 +67,3 @@ <p align="center">

Every time the `username` prop changes, its new value is sent into the stream. The stream debounces the input for two seconds, then maps it into an object (with a `type` of `localstorage`) under the key `payload`. Each time an effect is emitted from this pipeline, the handler calls `localstorage.setItem` with the effect's `payload` property.
Every time the `username` prop changes, its new value is sent into the stream. The stream debounces the input for two seconds, then maps it into an object (with a `type` of `localstorage`) under the key `value`. Each time an effect with the correct type is emitted from this pipeline, the handler calls `localstorage.setItem` with the effect's `name` and `value` properties.

@@ -99,5 +99,5 @@ ```js

- The `initialProps` are all props passed into the `WrappedComponent`.
- The `component` is an object which lets you observe your React component.
- Within the body of the function, you observe the event source you choose, pipe the events through your stream library of choice, and return a single stream of effects.
* The `initialProps` are all props passed into the `WrappedComponent`.
* The `component` is an object which lets you observe your React component.
* Within the body of the function, you observe the event source you choose, pipe the events through your stream library of choice, and return a single stream of effects.

@@ -110,5 +110,5 @@ ### Handler

- The `initialProps` are all props passed into the `WrappedComponent`.
- The `effect` is each event emitted by your `aperture`.
- Within the body of the function, you call any side-effects imperatively.
* The `initialProps` are all props passed into the `WrappedComponent`.
* The `effect` is each event emitted by your `aperture`.
* Within the body of the function, you call any side-effects imperatively.

@@ -121,7 +121,7 @@ ### withEffects

- The hoc takes in three curried arguments:
- A `handler` function
- An `aperture` function
- A React `Component`
- The hoc returns a `WrappedComponent` - an enhanced version of your original `Component` which includes your side-effect logic.
* The hoc takes in three curried arguments:
* A `handler` function
* An `aperture` function
* A React `Component`
* The hoc returns a `WrappedComponent` - an enhanced version of your original `Component` which includes your side-effect logic.

@@ -128,0 +128,0 @@ # Documentation

import { Listener } from './observable'
export interface PropListeners {
export interface KeyedListeners {
[key: string]: Array<Partial<Listener<any>>>

@@ -11,4 +11,5 @@ }

allProps: Array<Partial<Listener<any>>>
props: PropListeners
fnProps: PropListeners
props: KeyedListeners
fnProps: KeyedListeners
event: KeyedListeners
}

@@ -19,1 +20,3 @@

export type ErrorHandler<P> = (intialProps: P) => (error: any) => void
export type PushEvent = (eventName: string) => <T>(val: T) => void

@@ -7,2 +7,3 @@ import xs, { Stream, Listener, Subscription } from 'xstream'

observe: <T>(propName: string) => Stream<T>
event: <T>(eventName: string) => Stream<T>
mount: Stream<any>

@@ -9,0 +10,0 @@ unmount: Stream<any>

import * as React from 'react'
import { PropListeners, Listeners, Handler, ErrorHandler } from './baseTypes'
import {
KeyedListeners,
Listeners,
Handler,
ErrorHandler,
PushEvent
} from './baseTypes'
import {
Subscription,

@@ -17,3 +23,3 @@ Listener,

) => (aperture: Aperture<P, E>) => (
BaseComponent: React.ComponentType<P>
BaseComponent: React.ComponentType<P & { pushEvent: PushEvent }>
): React.ComponentClass<P> =>

@@ -25,2 +31,3 @@ class WithEffects extends React.PureComponent<P> {

private sinkSubscription: Subscription
private pushEvent: PushEvent

@@ -35,5 +42,11 @@ constructor(props: any, context: any) {

props: {},
fnProps: {}
fnProps: {},
event: {}
}
this.pushEvent = (eventName: string) => <T>(val: T) => {
const listeners = this.listeners.event[eventName] || []
listeners.forEach(listener => listener.next(val))
}
Object.keys(props).forEach(propName => {

@@ -95,7 +108,21 @@ const prop = props[propName]

const createSignalObservable = <T>(eventName: string) => {
return createObservable<T>(listener => {
this.listeners.event[eventName] = (
this.listeners.event[eventName] || []
).concat(listener)
return () => {
this.listeners.event[eventName].filter(
l => l !== listener
)
}
})
}
this.component = {
mount: mountObservable,
unmount: unmountObservable,
observe: <T>(propName?: string) =>
createPropObservable<T>(propName)
observe: createPropObservable,
event: createSignalObservable
}

@@ -141,3 +168,5 @@

BaseComponent,
Object.assign({}, this.props, this.decoratedProps)
Object.assign({}, this.props, this.decoratedProps, {
pushEvent: this.pushEvent
})
)

@@ -144,0 +173,0 @@ }

import { Listener } from './observable'
export interface PropListeners {
export interface KeyedListeners {
[key: string]: Array<Partial<Listener<any>>>

@@ -9,6 +9,8 @@ }

allProps: Array<Partial<Listener<any>>>
props: PropListeners
fnProps: PropListeners
props: KeyedListeners
fnProps: KeyedListeners
event: KeyedListeners
}
export declare type Handler<P, E> = (intialProps: P) => (val: E) => void
export declare type ErrorHandler<P> = (intialProps: P) => (error: any) => void
export declare type PushEvent = (eventName: string) => <T>(val: T) => void

@@ -5,2 +5,3 @@ import xs, { Stream, Listener, Subscription } from 'xstream'

observe: <T>(propName: string) => Stream<T>
event: <T>(eventName: string) => Stream<T>
mount: Stream<any>

@@ -7,0 +8,0 @@ unmount: Stream<any>

/// <reference types="react" />
import * as React from 'react'
import { Handler, ErrorHandler } from './baseTypes'
import { Handler, ErrorHandler, PushEvent } from './baseTypes'
import { Aperture } from './observable'

@@ -10,2 +10,8 @@ export declare const withEffects: <P, E>(

aperture: Aperture<P, E>
) => (BaseComponent: React.ComponentType<P>) => React.ComponentClass<P>
) => (
BaseComponent: React.ComponentType<
P & {
pushEvent: PushEvent
}
>
) => React.ComponentClass<P>
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