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

[@thi.ng/rdom] setScheduler not behaving as expected #402

Open
maxsei opened this issue Jul 26, 2023 · 0 comments
Open

[@thi.ng/rdom] setScheduler not behaving as expected #402

maxsei opened this issue Jul 26, 2023 · 0 comments

Comments

@maxsei
Copy link

maxsei commented Jul 26, 2023

It seems that setScheduler(new RAFScheduler()) does not behave properly because the number of job objects are out of sync with the DOM objects that are created (more DOM object are created that actually exists in the jobs stream). The only way I can have the list of jobs synced with the DOM is by using syncRAF.

import { defAtom, defCursor } from "@thi.ng/atom";
import * as rx from "@thi.ng/rstream";
import { $compile, $list, setScheduler, RAFScheduler } from "@thi.ng/rdom";

// setScheduler(new RAFScheduler());

const db = defAtom<State>({ jobs: [] });
const jobs = defCursor(db, ["jobs"]);
const jobsView = rx.syncRAF(rx.fromAtom(jobs))
const jobCreate = rx.stream<Job>();
jobCreate.subscribe({
  next: ({ start, end, ...rest }) => {
    jobs.swap((prev) => [
      ...prev,
      { ...rest, start: new Date(start), end: end && new Date(end) },
    ]);
  },
});

tx.run(
  tx.sideEffect((x) => jobCreate.next(x)),
  getJobs(), // not implemented here returns Job[]
);


const root = document.getElementById("root")
$compile($list(jobs, "div", {}, (x)=> `${x.start}`)).mount(root)
postspectacular added a commit that referenced this issue Jan 14, 2024
BREAKING CHANGE: remove scheduler, update IComponent and
various DOM update fn signatures

- remove scheduler support since never used (other than
  default/dummy `NullScheduler`) and `RAFScheduler` logic is
  better handled via `synRAF()` or similar (also see #402)
- update IComponent.mount() signature to use `ParentNode
  as type for `parent` arg, e.g. to support use w/ `ShadowRoot`
- update various DOM update fns with same parent arg type
- update all utility components/wrappers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant