Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/recksjs/recks

🐶 React-like RxJS-based framework
https://github.com/recksjs/recks

dom framework jsx react rxjs typescript

Last synced: 6 days ago
JSON representation

🐶 React-like RxJS-based framework

Awesome Lists containing this project

README

        

# Intro to RecksJS

[![NPM](https://img.shields.io/npm/v/recks)](https://www.npmjs.com/package/recks) [![Bundlephobia](https://img.shields.io/bundlephobia/minzip/recks?label=gzipped)](https://bundlephobia.com/result?p=recks@latest) [![MIT license](https://img.shields.io/npm/l/recks)](https://opensource.org/licenses/MIT)

> Official docs: [**recks.gitbook.io**](https://recks.gitbook.io)

RecksJS is a **framework based on streams**

```jsx
import Recks from 'recks';
import { timer } from 'rxjs';

function App() {
const ticks$ = timer(0, 1000);

return


{ ticks$ }


seconds passed



}
```

Try it in this [**online sandbox**](https://codesandbox.io/s/recks-example-greeting-input-tu6tp?file=/src/App.jsx) or [**install locally**](https://recks.gitbook.io/recks/install)

⚠️ RecksJS is currently in beta

## 🔎 Overview

Observables are first class citizens in Recks ❤️

```jsx
function App() {
return

{ timer(0, 1000) }

}
```

You can also do other way around: map a stream on JSX

```jsx
function App() {
return timer(0, 1000).pipe(
map(x =>

{ x }
)
);
}
```

_Recks will subscribe to and unsubscribe from provided streams automatically, you don't have to worry about that!_

And you can use Promises that will display the result, once resolved:

```jsx
function App() {
const result = axios.get(url).then(r => r.data);

return


{ result }

}
```

To get a better understanding of Recks concepts, read this article: ["Intro to Recks: Rx+JSX experiment"](https://dev.to/kosich/recks-rxjs-based-framework-23h5) and check out [API](https://recks.gitbook.io/recks/api/) docs section

## 📖 Examples

### 1. Hello world

Just a basic, no "moving parts"

```jsx
import Recks from 'recks';

function App() {
return

Hello world!


}
```

### 2. Timer

RxJS' timer here will emit an integer every second, updating the view

```jsx
import Recks from 'recks';
import { timer } from 'rxjs';

function App() {
const ticks$ = timer(0, 1000);

return


{ ticks$ }


seconds passed



}
```

[online sandbox](https://codesandbox.io/s/recks-example-timer-fjyvj?fontsize=14&hidenavigation=1&theme=dark&module=/src/App)

### 3. Greeting

Uses a simple [Subject](https://rxjs.dev/api/index/class/Subject) to store local component state:

```jsx
import Recks from 'recks';
import { Subject } from 'rxjs';
import { map, startWith } from 'rxjs/operators';

function App() {
const name$ = new Subject();
const view$ = name$.pipe(
map(x => x ? `Hello, ${x}!` : ''),
startWith('')
);

return


name$.next(e.target.value)}
/>
{ view$ }

}
```

[online sandbox](https://codesandbox.io/s/recks-example-greeting-input-tu6tp?fontsize=14&hidenavigation=1&theme=dark&module=/src/App)

### 4. Counter

Traditional counter example with a [Subject](https://rxjs.dev/api/index/class/Subject):

```jsx
import Recks from 'recks';
import { Subject } from 'rxjs';
import { scan, startWith } from 'rxjs/operators';

function App() {
const input$ = new Subject();
const view$ = input$.pipe(
startWith(0),
scan((acc, curr) => acc + curr)
);

return


input$.next(-1) }>
minus

{ view$ }

input$.next( 1) }>
plus


}
```

[online sandbox](https://codesandbox.io/s/recks-example-counter-lw29e?fontsize=14&hidenavigation=1&theme=dark&module=/src/App)

## 📚 Docs

Continue reading:

* \*\*\*\*[**Installation guide**](https://recks.gitbook.io/recks/install)\*\*\*\*
* [Lifecycle](https://recks.gitbook.io/recks/api/lifecycle)
* [Events](https://recks.gitbook.io/recks/api/events)
* [Subcomponents](https://recks.gitbook.io/recks/api/subcomponents)
* [Lists](https://recks.gitbook.io/recks/api/lists)
* [DOM references](https://recks.gitbook.io/recks/api/dom-references)