bordoley / rx-reason

Reactive programming library for ReasonML/OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Revamp the scheduler API

bordoley opened this issue · comments

commented

The current api works but tends to depend upon closure, which can be a performance bottleneck. Instead we can redefine a scheduler as:

type t = {
  schedule:
    'state .
    (('state => unit, 'state) => unit, 'state) => Disposable.t,

};

let immediate: t = {
  schedule: (work, state) => {
    let rec continuation = state => work(continuation, state);
    work(continuation, state);
    Disposable.disposed;
  },
};

And define a delay scheduler as:

type t = {
  schedule:
    'state .
    (~delay=float, ((~delay=float, 'state) => unit, 'state) => unit, 'state) => Disposable.t,
};
commented

landed a big refactor. Still more tweaks to be made.