1.0.5 • Published 2 years ago

@wuchuheng/rxjs v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Description

This is a library for communication between components, similar to redux, but it is simpler and easier to use.

Installing

$ npm i @wuchuheng/rxjs

Usage

step1 declare Scheduler for communication between components

import SubscriptionService from "@wuchuheng/rxjs";

// This is a scheduler where all the subscribers will be stored
class Scheduler {
    public static chatGroupObserve = new SubscriptionService<string>('');
}

step2 usage directly in components

import {useObserve} from "@wuchuheng/rxjs";

const componentA = () => {
    const [message, dispatcher] = useObserve(Scheduler.chatGroupObserve); 
    // a new message will be dispatch here. 
    return <input onchange={e => dispatcher.next(e.target.value)} />
}

const componentB = () => {
    // This hook will subscribe to the new message.
    const [message] = useObserve(Scheduler.chatGroupObserve);
    return <>{message}</>
}

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago