Giter Club home page Giter Club logo

evemin's People

Contributors

betula avatar

Stargazers

 avatar  avatar

Watchers

 avatar

evemin's Issues

proposal: entity from subdirectory

import { event } from 're-event/entity';

const ev = event();

const f = ev.map(v => v * 10).filter(v => v);

f.listen(v => console.log(v));

without entity

import { event, map, filter, listen } from 'rvent';

const ev = event();

const f = event(ev, map(v => v * 10), filter(v => v));
listen(f, v => console.log(v));

last one)

import E from 're-event';

const ev = E.event();
const f = E.event(ev, E.map(v => v * 10), E.filter(v => v));
E.listen(f, v => console.log(v));

performance issue: make two struct of subscribers.

I will store all subscribers in the Set.

(new Set()).add(subscriber)

But I think iteration of the set should be an expensive operation, and the better one is the suppose both operations.

  • Set for storing list of subscribers and effective unlinking.
  • Compiled functions to one for the subscription.
const fn = (v) => (listener(v), top_fn(v));
top_fn = fn;
const fire_stack = [];
const call_node(v) => {
  // stack_start
  top_fn(v);
  // collect fires

Performance test should be next issue)

perf idea: attach should return first argument

const listen = (ev, fn) => {
  if (ev[1].indexOf(fn) === -1) ev[1] = ev[1].concat(fn);
  return () => {
    ev[1] = ev[1].filter(f => f !== fn);
  }
}

will be

const listen = (ev, fn) => (
  ev[1].indexOf(fn) === -1 && ev[1] = ev[1].concat(fn),
  attach(() => (ev[1] = ev[1].filter(f => f !== fn)))
)

nested syntax proposal

const a = event()

const b = event(a, map(v => v + 1), filter(v => v) /*, listen(v => console.log(v) */)

const unsub = listen(b, v => console.log(v))

Sure compatible with unsubscriber

proposal improvement: detach listener and attach

listen: (ev, fn) => (
    ev[0].indexOf(fn) < 0 && (ev[0] = ev[0].concat(fn)),
    () => {
      let i = ev[0].indexOf(fn)
      i > -1 && ev[0].splice(i, 1) // error here with iteration exactly all listeners in "ev" function
    }
  )

Reason:

  • If I detach another listener in the body of one listener, another listener should never be called.
  • If I attach the new listener in the body of one listener, the new listener should be called only on the next reaction.

renaming: rename "event" to "<anything elese>"

Because "event" is deprecated js keyword in dom env))

var event: Event | undefined
@deprecated

'event' is deprecated.ts(6385)
lib.dom.d.ts(17678, 5): The declaration was marked as deprecated here.
Object is possibly 'undefined'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.