Skip to content

Alternative APIs #3

@kosich

Description

@kosich

Here we're exploring API suggestions that might be handy or help with handling README#precautions:

  1. Expression with explicit dependencies by @voliva :
const a = timer(0, 1000);
const b = timer(0, 1000);
const c = computed((a, b) => a + b,  a, untrack(b)))

This will react to every change and is side-effect safe
It's basically a combineLatest + withLatestFrom + map — most honest way to react to every Observable emission

  1. Async/await syntax:
const a = timer(0, 1000);
const b = timer(0, 1000);
const c = computed(async () => await $(a) + await $(b))

It might react to every change, and is side-effect safe

  1. Provide initial value via tracker by @loreanvictor

Trackers might with initial value (default value?)

const a = interval(1000);
const b = timer(500);
const c = computed(() => $(a, 42) + _(b, 'hi!'));
// > 42 hi!
// > 0 0
// > 1 0
// > …
  1. String tag tracker by @voliva & @loreanvictor:
const a = timer(0, 1000);
const b = tagger`${ a } 🦔`;
// > 0 🦔
// > 1 🦔
// > ...

Alternatives:

  1. we can have tagger to be equivalent of a tracker with concatenation

  2. string expression might be evaluated

--

Suggested APIs can co-exist with the original one, available via different names.

--

If you have an idea — please, add a comment describing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions