You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, if we're creating an object that needs reactive access to data, we don't need to expose the underlying implementation -- we can rely on getters (and setters, if needed), to make signals behave like "just javascirpt properties".
In providing a reactive property to a class, Board, we can define a property, previous that just is reactive, because it delays the read of the signal until the read of the previous property.
Shown here, using the @signal decorator idea from the readme:
classDemo{
@signalprevious= ...;// a class method(tm)createBoard=(x,y)=>{letstate=this;returnnewBoard(x,y,{getprevious(){returnstate.previous;}});};}
With this approach, the API of Board doesn't need to change to support any style of signals.
So, I suppose, more generally, should we try to come up with a list of tips'n'things like this?
My worry, is that we'll give folks a sharp tool, and they'll leave sharp edges on their api boundaries (or other places!), which make broader usage of Signals (or rather the integration between JS Frameworks) potentially more difficult.
The text was updated successfully, but these errors were encountered:
For example, if we're creating an object that needs reactive access to data, we don't need to expose the underlying implementation -- we can rely on getters (and setters, if needed), to make signals behave like "just javascirpt properties".
In providing a reactive property to a class,
Board
, we can define a property,previous
that just is reactive, because it delays the read of the signal until the read of theprevious
property.Shown here, using the
@signal
decorator idea from the readme:or using signals directly, maybe, less tied to what I'm immediately working on:
With this approach, the API of
Board
doesn't need to change to support any style of signals.So, I suppose, more generally, should we try to come up with a list of tips'n'things like this?
My worry, is that we'll give folks a sharp tool, and they'll leave sharp edges on their api boundaries (or other places!), which make broader usage of Signals (or rather the integration between JS Frameworks) potentially more difficult.
The text was updated successfully, but these errors were encountered: