Skip to content

ExtensibilityΒ #3

@kosich

Description

@kosich

It'd be good to have ability to extend some levels of proxify, e.g.:

Rx Simple State example

// create a state
const state = createState({ count: 0, timer: 100 });

// listen to state changes
state.count.subscribe(c => console.log('C:', c)); // > C:0

// write to the state
state.count.next(1); // > C:1

// reset the state
state.next({ timer: 2, count: 2 }) // > C:2

state.count += 1; // > C:3
state.count.next(3); // ignored: same value

// read current values:
console.log(state.timer + state.count); // > 2 + 3 = 5

OR to be able to add rxjs-autorun functions, e.g.:

// pseudocode
// state.js
import { $, _ } from 'rxjs-autorun';

export const State = v => proxify(
  new BehaviorSubject(v), // base
  { $, _ } // extender
);

// index.js
import { run } from 'rxjs-autorun';
import { State } from './state';

const state = State(0);
run(() => state.$ + ' πŸ‘'); // > 0 πŸ‘
state.next(1); // > 1 πŸ‘

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions