- The static
stateVars()
getter method should now return an object with in the keys the name of the stateVar and in the values the initial value of the stateVar. - The stateVar options were previously set with the static
stateVars()
getter method, but should now be specified with the staticstateVarOptions()
getter method. - Docs updated accordingly.
- Added some more descriptive comments in the code.
For non-decorator usage, update the static stateVar()
getter methods.
Change this:
class MyState extends LitState {
static get stateVars() {
return {
myStateVar: { option: 'value' }
};
}
constructor() {
super();
this.myStateVar = 'initial value';
}
}
To this:
class MyState extends LitState {
static get stateVars() {
return {
myStateVar: 'initial value'
};
}
static get stateVarOptions() {
return {
myStateVar: { option: 'value' }
};
}
}
If the options object is empty, you don't need to specify the static
stateVarOptions()
getter method.
- When a component gets dynamically removed from the DOM and then added again,
call
this.requestUpdate()
so that the observers get-readded again. Fixes issue #5. - Added a docs page for this use case.
- Reordered docs menu.
- Added some comments in the code.
- The way
stateVar
variables are defined has changed. You have to update this coming from 1.5.0. - Now you can use decorators to specify your stateVars, use
@stateVar() myVar = 'initial value';
in your state class. - You can also still define
stateVar
variables without decorators. It is done in a similar way LitElement does. Check the docs for this. - Updated LitDocs and documentation content.
- Overall refactors.
Update the stateVar
definitions, instead of:
myData = stateVar('value');
Do this:
@stateVar() myData = 'value';
For no-decorator usage, look in the docs.
- The
asyncStateVar
is now available here so that LitState is tiny for projects that don't useasyncStateVar
. - Updated docs and demo app.
- Making mixin usage the primary means for making your components state-aware.
- Renamed the mixin class
LitStateElementMixin
toobserveState
, reads nicer, looks better, is shorter. - Updated docs and demo app to use the new mixin class.
LitState
is now not dependend on theStateVar
andAsyncStateVar
classes. There's oneBaseStateVar
class which all types of stateVar classes should extend from.LitState
recognizes this as a stateVar, and then handles the handling of theget
andset
traps to the stateVar. This allows for the possibility to factor outAsyncStateVar
to a separate library, making LitState smaller. Because not all apps always needAsyncStateVar
. It also allows for easily adding more (custom) types of stateVars, to extend LitState.- Some more general refactors to make things simpler.
- Reordered some texts in README
- Fixed bug where
isRejectedGet()
still returnedtrue
when asetValue()
failed after it, andisRejectedSet()
still returnedtrue
when agetValue()
failed after it.
- Updated Readme
- Updated Readme
- Assigning to an
asyncStateVar
now throws an error, you have to usesetValue()
. This to make usage consistent. setValue()
doesn't return a promise anymore._pendingCache
is always set tofalse
whensetValue()
succeeds, sopushCache()
doesn't needsetValue()
to return a promise anymore.- Removed unnecessary
logStateVar()
calls forasyncStateVar
. Only components that callgetValue()
need to re-render when the var changes. - Added demo page for components that show different state variables on re-renders.
- Overall demo app refactors and UI/text improvements.
- Added
setCache(value)
andpushCache()
functionality toasyncStateVar
. - Added demo page for
setCache(value)
andpushCache()
. - Updated readme.
- Created mixin
LitStateElementMixin
. - Added demo page for mixin
LitStateElementMixin
. - Updated demo app internals.
- Created changelog.
- Changed behavior of
asyncStateVar()
:- You can now have a getter and setter.
getValue()
won't return the error from the promise's reject callback in case of an error anymore. You can get the error with the methodgetError()
(for the error of the last get or set),getErrorGet()
(for the error of the last get) orgetErrorSet()
(for the error of the last set).
- Updated demo app to showcase
asyncStateVar
better.