async_state_view 0.2.0
async_state_view: ^0.2.0 copied to clipboard
Render retained asynchronous state without owning or restarting the work.
0.2.0 #
- Breaking: States compare by value instead of by identity, so a selector
can skip rebuilds while the part of a state it maps to is unchanged.
- Owners that skip equal states, such as
ValueNotifier, Bloc and Riverpod 3 notifiers, no longer notify when a state is published again with an equal value. This also applies to objects that compare a state as one of their fields, such as Equatable or freezed Bloc states. - After changing a list in place,
AsyncData(items)equals the current state; publish a new list instead. - A state can no longer be a key of a constant map or an element of a
constant set; drop
constfrom the collection. - A constant pattern such as
case const AsyncLoading():matches every equal state, including one created withoutconst, instead of only the identical constant. - Equality ignores the type argument, so
const AsyncLoading()equals anAsyncLoading<User>().
- Owners that skip equal states, such as
- Breaking:
AsyncStatehas new members. They take precedence over extension members with the same names, so an extension you wrote for 0.1.0 is no longer called, or no longer compiles if its signature differs. Remove it or rename its members. The new members are:toLoadingto refresh, andtoErrorto report a failure, while keeping the current value.mapValueto transform a state's value while keeping its kind.withoutCarriedValueto drop the value a loading or error state carries, such as to skip rebuilds on progress updates.- The
hasValue,valueOrNullandrequireValueaccessors. Without a value,requireValuerethrows an error with its stack trace.
- Add
AsyncLoading.withValueandAsyncError.withValueto carry a value: partial progress or the previous result while refreshing, and the previous result after a failed refresh. Existing states are unaffected; code that switches on states created elsewhere should checkhasValueif it can receive one. - Add
AsyncStateBuilder.loadingWithValueandAsyncStateBuilder.errorWithValueto render a carried value. Without them, a loading state with a value uses theloadingbuilder and an error with a value uses theerrorbuilder, so a builder renders exactly as in 0.1.0 until it opts in. - Add the
AsyncStateErrorWithValueBuildertypedef forerrorWithValue. - States describe themselves in
toString. - Document reporting progress from a stream, with a complete
ChangeNotifierexample.
0.1.0 #
- initial release