upgrade: timer package upgrade for Solid 2.0#843
Draft
davedbase wants to merge 3 commits intosolidjs-community:mainfrom
Draft
upgrade: timer package upgrade for Solid 2.0#843davedbase wants to merge 3 commits intosolidjs-community:mainfrom
davedbase wants to merge 3 commits intosolidjs-community:mainfrom
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reimplements the timer package for
solid-js@2.0.0.makeTimerno longer auto-registers withonCleanup— it returns a cleanup function and lets the caller decide.createTimerandcreateTimeoutLoopcallonCleanup(makeTimer(...))at their own call sites. This aligns with themake*/create*naming convention used across solid-primitives.isServeris now imported from@solidjs/web(moved out ofsolid-js/webin 2.0).createEffectupdated to the split compute/apply model:createEffect(compute, apply). The apply phase returns a cleanup function instead of usingonCleanup(which doesn't work in the apply phase).batchremoved — signal writes are auto-batched via microtask in 2.0. Tests useflush()where synchronous commitment is needed.createTimer(fractional delay carry-over) is rewritten to manage the full timer lifecycle directly in the apply cleanup closure, replacing the 1.x signal self-trigger trick.Bug fix:
createPolled— issue #808The original implementation used
createMemo(() => createSignal(fn(value), options))and calledmemo()[1](fn)from the timer. In production buildsmemo()[1]wasundefined, crashing on every timer tick.The fix captures the signal setter in a closure variable that is updated each time the memo re-runs:
I'm not fully confident in this
createPolledfix and would welcome a second look. The main concern is whether capturingsetin a closure and updating it on each memo re-run (dep change) is the right pattern in Solid 2.0, or whether there's a cleaner approach using the new writable derived signal (createSignal(computeFn, initialValue, options)) that avoids the TypeScript overload discrimination issues we ran into.