https://github.com/notests/rxfeedback.js
Architecture for RxJS
https://github.com/notests/rxfeedback.js
architecture rxjs
Last synced: about 1 year ago
JSON representation
Architecture for RxJS
- Host: GitHub
- URL: https://github.com/notests/rxfeedback.js
- Owner: NoTests
- License: mit
- Created: 2018-02-27T21:57:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-17T19:29:48.000Z (about 7 years ago)
- Last Synced: 2025-04-15T22:59:01.380Z (about 1 year ago)
- Topics: architecture, rxjs
- Language: TypeScript
- Homepage:
- Size: 90.8 KB
- Stars: 11
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/NoTests/RxFeedback.js) [](http://badge.fury.io/js/rxfeedback)
#### RxFeedback
TypeScript/JavaScript version of [RxFeedback](https://github.com/kzaher/RxFeedback)
[20min video pitch](https://academy.realm.io/posts/try-swift-nyc-2017-krunoslav-zaher-modern-rxswift-architectures/)
The simplest architecture for [RxJS](https://github.com/ReactiveX/RxJS)

```typescript
type FeedbackLoop =
(state: rx.Observable, scheduler: IScheduler) => rx.Observable;
declare module 'rxjs/Observable' {
namespace Observable {
function system(
initialState: State,
reduce: (state: State, event: Event) => State,
feedback: FeedbackLoop[],
): Observable;
}
}
```
# Why
* Straightforward
* If it did happen -> Event
* If it should happen -> Request
* To fulfill Request -> Feedback loo
* Declarative
* System behavior is first declaratively specified and effects begin after subscribe is called => Compile time proof there are no "unhandled states"
* Debugging is easier
* A lot of logic is just normal pure function that can be debugged using Xcode debugger, or just printing the commands.
* Can be applied on any level
* [Entire system](https://kafka.apache.org/documentation/)
* application (state is stored inside a database, CoreData, Firebase, Realm)
* view controller (state is stored inside `system` operator)
* inside feedback loop (another `system` operator inside feedback loop)
* Works awesome with dependency injection
* Testing
* Reducer is a pure function, just call it and assert results
* In case effects are being tested -> TestScheduler
* Can model circular dependencies
* Completely separates business logic from effects (Rx).
* Business logic can be transpiled between platforms
### Installing with [NPM](https://www.npmjs.com/)
```bash
$ npm install rxfeedback
```
```typescript
import * as RxFeedback from 'rxfeedback';
```