Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a somewhat substantial refactor of the core of Starbeam to address some timing issues that came up when trying to do more elaborate demos. It also culls a decent amount of development cruft, and consolidates duplicate concepts that arose from codebase iteration.
Some big-picture changes:
Cell
s are now reliably initialized with the timestamp at the point of initialization. This means that when a brand new cell is added to a frame, the frame's timestamp will be at least as current as the time the cell was created. While these timing concerns tended to work out before, they were not well specified and were the source of bugs in the core composition that were tricky to track down or address.@starbeam/timeline
. This made it possible to write unit-style tests against@starbeam/timeline
that more directly assert low-level details. Along the same lines, this PR makes it easy to implement core interfaces (such asReactiveInternals
) with simple POJOs. Previously, the interfaces were defined in@starbeam/timeline
, but they were annoying to implement, and the codebase practically assumed that you would use concrete implementations provided by@starbeam/core
.ReactiveProtocol
. Previously, some composition was described in terms ofReactiveProtocol
, but there were many APIs that usedReactive<T>
orReactiveInternals
instead. This PR isn't an exhaustive migration toReactiveProtocol
, and follow-up PRs will finish the job..current
property onReactive<T>
in favor of aread()
method. That change simplifies code that composes overReactive<T>
, and bothCell<T>
andFormulaFn<T>
still have.current
properties. I expect to do some follow-up work to make sure that the.current
convenience is available when using any of the high-level APIs.Setup
concept, which makes it possible to have auto-validating lifecycle hooks, was also significantly simplified.Setup
was a recently added API, and because it's designed to deterministically perform setup and cleanup, the exact timing semantics was much less forgiving. BuildingSetup
on the rigorously defined timing semantics of@starbeam/timeline
addressed all of the open issues I was tracking.Formula
toFormulaFn
, and repurposed the nameFormula
for a lower-level API that makes it possible to validate the formula without recomputing it. This previously existed asFormulaState
and direct invocations ofTIMELINE.evaluateFormula
, but both of those APIs were too cumbersome and caveated for third-party abstraction builders. The newFormula
API is intended to evolve into a fully public API that is used by power users. That said, I may switch the naming back toFormula
andFormulaSomethingElse
before 0.6.@starbeam/timeline
and@starbeam/core
, fixing the open problems I was tracking directly.@starbeamx
packages were refreshed to use the new APIs.ReactiveProtocol
and are working.@starbeamx/devtools
) were refreshed to fix type error and lint errors, but I have not tested them yet and don't expect them to work yet. A follow-up PR will get them working again (at least as well as they were working before).Removed
layout
andidle
lifecycle events. I plan to bring something like this back, but base it more closely on normal resources (previously,DOMResource
duplicated quite a bit of functionality for no good reason).TIMELINE.on.change
, such asTIMELINE.render
,Pollable
,Pollables
,Renderables
, etc.TIMELINE.on.change
now fires synchronously, which allows renderers to use their framework's specific timing behavior. It is now illegal to read from cells or write to cells in an.on.change
handler. Instead, renderers should do the minimum possible to cause their framework to re-render the component (and therefore cause the reactive value to be polled). For example, the React renderer simply notifies React (using auseState
variable). This operation simply tells React to enqueue a task that renders the component (if one was not already enqueued), and does not read or write from any Starbeam cells.Probable Regression in Description Threading and Dev-Mode Assertions
This change affected quite a bit of code that threaded descriptions through various abstractions (and tagging the description with the correct stack). It also changed a lot of the fundamental code involved in the untracked consumption error in #25.
These are all temporary regressions that will be addressed immediately in follow-up PRs.
The Timing