What's new in v4.1.0
The new update comes with big updates. Signals are now available in core package. This big feature enables plugin system. Not only this, the routing mechanism got few updates. The ecosystem finally got Forms scoped package which enable seemless form creation (this is in its nacent stage).
Signals
This is the most important inclusion in core package. Signals now enable more flexibility in creating utilities. Best example is forms package. This package expose FormBuilder class to define forms. it is just a class not a component / service. so how it introduced reactivity is via signals.
How to create a signal
Simple.
- import
signalfrom@plumejs/core - in
beforeMountlifecycle hook initiate signal asthis.your_variable = signal(1).
a. Note the signals should be initiated inbeforeMountlifecycle only.
b. Note the signal requires initial value. If you are using typescript, the type of signal is infered from the initial value. - to read the signal value:
this.your_variable() - to update the signal value call:
this.your_variable.set(2)orthis.your_variable.set((initialVal) => initialVal + 1) - As soon as the
setis called, it register re-render signal of component. with this, even though you are using multiple signals and setting multiple signal values the re-render occurs once.
Breaking Changes
The new update also got some breaking changes too:
onbindpropswill not work. instead pass the props usingdata-inputattribute on child component. This helps code to be more readable and less verbose.- all types of hooks are removed in-favor of signals. infact Signals will support any type of data.