All Projects → Raiondesu → vuse-rx

Raiondesu / vuse-rx

Licence: MIT license
Vue 3 + rxjs = ❤

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to vuse-rx

vue-next-rx
RxJS integration for Vue next
Stars: ✭ 31 (-40.38%)
Mutual labels:  rxjs, vue3, composition-api, vue-next
Ayanami
🍭 A better way to react with state
Stars: ✭ 129 (+148.08%)
Mutual labels:  rxjs, state-management, reactive-programming
vue-unstated
A tiny state management library for Vue Composition API.
Stars: ✭ 30 (-42.31%)
Mutual labels:  state-management, vue3, composition-api
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (-51.92%)
Mutual labels:  state-management, state, vue3
RxReduxK
Micro-framework for Redux implemented in Kotlin
Stars: ✭ 65 (+25%)
Mutual labels:  state-management, state, rx
React Easy State
Simple React state management. Made with ❤️ and ES6 Proxies.
Stars: ✭ 2,459 (+4628.85%)
Mutual labels:  state-management, state, reactive-programming
ReduxSimple
Simple Stupid Redux Store using Reactive Extensions
Stars: ✭ 119 (+128.85%)
Mutual labels:  state-management, state, reactive-programming
React Composition Api
🎨 Simple React state management. Made with @vue/reactivity and ❤️.
Stars: ✭ 67 (+28.85%)
Mutual labels:  state-management, state, reactive-programming
Toy Rx
A tiny implementation of RxJS that actually works, for learning
Stars: ✭ 290 (+457.69%)
Mutual labels:  rxjs, reactive-programming, rx
Reactive.how
Learn reactive programming with animated cards.
Stars: ✭ 592 (+1038.46%)
Mutual labels:  rxjs, reactive-programming, rx
Cyclejs
A functional and reactive JavaScript framework for predictable code
Stars: ✭ 9,996 (+19123.08%)
Mutual labels:  rxjs, reactive-programming
Bloc.js
A predictable state management library that helps implement the BLoC design pattern in JavaScript
Stars: ✭ 111 (+113.46%)
Mutual labels:  rxjs, state-management
Rx React Container
Use RxJS in React components, via HOC or Hook
Stars: ✭ 105 (+101.92%)
Mutual labels:  rxjs, rx
Rxios
A RxJS wrapper for axios
Stars: ✭ 119 (+128.85%)
Mutual labels:  rxjs, rx
kendo-vue
Issue tracker - Kendo UI for Vue http://www.telerik.com/kendo-vue-ui/
Stars: ✭ 49 (-5.77%)
Mutual labels:  reactive-programming, vue3
Rxviz
Rx Visualizer - Animated playground for Rx Observables
Stars: ✭ 1,471 (+2728.85%)
Mutual labels:  rxjs, rx
Od Virtualscroll
🚀 Observable-based virtual scroll implementation in Angular
Stars: ✭ 133 (+155.77%)
Mutual labels:  rxjs, reactive-programming
Beicon
Reactive Streams for ClojureScript
Stars: ✭ 133 (+155.77%)
Mutual labels:  rxjs, reactive-programming
Store
Aurelia single state store based on RxJS
Stars: ✭ 103 (+98.08%)
Mutual labels:  rxjs, state-management
Cyclejs.cn
The Cycle.js Chinese documentation website.
Stars: ✭ 132 (+153.85%)
Mutual labels:  rxjs, reactive-programming

Complete first-class RxJS 7+ support for Vue 3

What is this?

vuse-rx is a bridge between Vue 3 and RxJS: it connects reactive states and refs with observables and subjects in a way that enforces separation of concerns and drastically reduces the amount of boilerplate code.

The highlights are:

  • useRxState - flux-like state management with observables;
  • syncRef - synchronize two refs with either one-way or two-way binding;
  • fromRef - create an observable from any ref or watch source;
  • refFrom - create a ref from a promise/observable/iterable/generator or anything else;

See the docs for more information

Install

npm i -S vuse-rx

yard add vuse-rx

Use

Below is a simple example of a counter component with a state and two simple reducers. See the docs for a more detailed and interactive example.

<script lang="ts">
import { useRxState, syncRef } from 'vuse-rx';
import { defineComponent, toRef } from 'vue';
import { tap } from 'rxjs/operators';

export default defineComponent({
  setup() {
    const {
      actions: {
        increment,
        setCount
      },
      state,
      state$ // state observable
    } = useRxState({ count: 0 })({
      // stateful reducer with mutation context
      increment: () => (state, mutation) => ({
        // automatic type inference for the state
        count: state.count + 1
      }),

      // stateless reducer
      setCount: (count: string) => ({
        // custom business logic
        count: isNaN(Number(count)) ? 0 : Number(count)
      }),
    }, state$ => state$.pipe(tap(state => console.log('state is updated', state))));

    // "Activating" the actions
    state$.subscribe(state => console.log('counter: ', state.count));

    return {
      increment,
      setCount,
      state,

      // One-way data binding from reactive state (with type convertation)
      countRef: syncRef(toRef(state, 'count'), { to: String }),
    };
  }
});
</script>

<template>
  <p>Counter: {{ state.count }}</p>
  <button @click="increment">increment</button>
  <input v-model="countRef" @keyup.enter="setCount(countRef)"/>
</template>

Contributing

Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].