Giter VIP home page Giter VIP logo

kefir-react's Introduction

kefir-react

React wrapper component for linking Kefir.js observables as props value

Usage example

import { KefirReact } from 'kefir-react';

const myProperty = Kefir.fromPoll(1, () => new Date()})
    .toProperty(() => new Date());

class App extends React.Component {
    render() {
        return this.props.myValue;
    }
}

const AppWrapped = KefirReact(
    myProperty.map(myValue => { myValue }),
    App
);

class Main extends React.Component {
    render() {
        return React.createElement(AppWrapped);
    }
}

API

Exports KefirReact factory and KefirReactComponent react component

KefirReact

(props$, ComponentClass, [LoaderComponentClass]) -> WrappedComponentClass

So in props of instantiated ComponentClass there will be values from props$

LoaderComponentClass is optional. It'll be displayed until first value in props$.

Use kefir-combine-object to create props$

kefir-react's People

Contributors

iofjuupasli avatar dkvasnicka avatar

Stargazers

 avatar  avatar Logan Powell avatar Leechael avatar Daniele Piccone avatar Michal Kulinski avatar  avatar  avatar C.C. avatar  avatar Christoph Grabo avatar Arl Smith avatar timelyportfolio avatar  avatar Young avatar Roma P. avatar

Watchers

Petr Myazin avatar timelyportfolio avatar James Cloos avatar  avatar

kefir-react's Issues

Simplify API

const KefirReact = (observable, Component) => {
    return props => h(KefirReactComponent, {
        observable,
        render: values => h(Component, merge(props, values))
    });
}

class Test extends React.Component {
    render() {
        return h(KefirReact(stream, MyComponent));
    }
}

const Test = KefirReact(stream, MyComponent);

ReactDOM.render(
    h(KefirReact(stream, MyComponent)),
    $('#app')
);

And export both KefirReact and KefirReactComponent. The second can be used when observable depends on props.

But there is a problem with observable - it should be KefirObservable<props>, and in most cases it will be combined object of Observables. But it still not implemented in Kefir: https://github.com/rpominov/kefir/issues/143

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.