- 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.