2 ms·
I don't think that's a sync vs async difference in the API. peek() is related to reading the value without creating a subscription on it: https://preactjs.com/g
by esprehn 4y ago
I don't think that's a sync vs async difference in the API. peek() is related to reading the value without creating a subscription on it:
https://preactjs.com/guide/v10/signals#reading-signals-without-subscribing-to-them https://preactjs.com/guide/v10/signals#reading-signals-witho...
In general signals looks like a synchronous but lazy system. I don't see anything that's actually async in there?
- rektide 4y agoNot sure how you are getting this conclusion? The example code is as follows: effectCount = effectCount.peek() + 1; That is definitely absolutely clearly 100% for sure sync code. Adding a numerical value +1 to the result of a function (with no wait on it) makes it clear that .peek() here is synchronously returning a value.
- esprehn 4y agoCorrect, .value does exactly the same thing. The only difference is .value subscribes to updates. The framework is all synchronous (but sometimes lazy).