
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-flyd-class
Advanced tools
A thin layer between Flyd and React. Ported from react-reactive-class.
With React Flyd Class, you can create Reactive Components, which subscribe to flyd streams and re-render themselves.
You can compare this example to Counter example of Cycle.js and Counter example of Yolk.
import { stream, merge, scan } from 'flyd';
import React from 'react';
import ReactDOM from 'react-dom';
import { reactive } from 'react-flyd-class';
const Span = createReactiveClass('span');
function Counter () {
const plusClick$ = stream();
const minusClick$ = stream();
const action$ = merge(
plusClick$.map(() => 1),
minusClick$.map(() => -1)
);
const count$ = scan((x, y) => x + y, 0, action$);
return (
<div>
<div>
<button id="plus" onClick={ (e) => plusClick$(e) }>+</button>
<button id="minus" onClick={ (e) => minusClick$(e) }>-</button>
</div>
<div>
Count: <Span>{ count$ }</Span>
</div>
</div>
)
}
ReactDOM.render(<Counter />, document.getElementById('root'));
npm install --save react-flyd-class
Take full control of component lifecycle.
reactive(ReactClass): ReactClass
Example:
import { stream } from 'flyd';
import every from 'flyd/module/every';
import React from 'react';
import ReactDOM from 'react-dom';
import { reactive } from 'react-flyd-class';
class Text extends React.Component {
componentWillMount() {
console.log('Text will mount.');
}
render() {
console.log('Text rendered.');
return (
<div>{this.props.children}</div>
);
}
componentWillUnmount() {
console.log('Text will unmount.');
}
}
const ReactiveText = reactive(Text);
const currentTime$ = every(1000)
.map((t) => new Date(t).toLocaleString());
ReactDOM.render(
<ReactiveText>{ currentTime$ }</ReactiveText>,
document.getElementById('root')
);
You can use mount attribute to mount/unmount a component.
// Unmount this component if length of incoming text is 0.
<Span mount={ text$.map(text => text.length) }>
{text$}
</Span>
Source must be the only child when using observable as child component.
// This will not work
<Span>
Hello {name$}, how are you?
</Span>
// This will work
<span>
Hello <Span>{name$}</Span>, how are you?
</span>
Feel free to ask questions or submit pull requests!
The MIT License (MIT)
FAQs
create reactive react classes for flyd streams
We found that react-flyd-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.