Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensibility #3

Open
kosich opened this issue Sep 29, 2020 · 1 comment · May be fixed by #4
Open

Extensibility #3

kosich opened this issue Sep 29, 2020 · 1 comment · May be fixed by #4
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kosich
Copy link
Owner

kosich commented Sep 29, 2020

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 🐑
@kosich kosich added enhancement New feature or request help wanted Extra attention is needed labels Sep 29, 2020
@kosich kosich linked a pull request Oct 22, 2020 that will close this issue
@kosich
Copy link
Owner Author

kosich commented Oct 22, 2020

I've drafted this feature in #4, but want to hold it till we see more use-cases as it complicates types and code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant