remote_value 0.0.3 copy "remote_value: ^0.0.3" to clipboard
remote_value: ^0.0.3 copied to clipboard

discontinued
outdated

Package that implement remote value abstraction and add cubit to mange it.

remote_value #

remote_value implements remote data abstraction and integrate it with bloc(based on blop)

Support technique that can be applied to bloc like event transform, Bloc.listener and blop methods that add ability to extend behavior, used to implement PersistentValueBlop

remote_data

triple

install #

dependency: 
    remote_value: any

Features #

base usage #

class CurrentUserData extends RemoteValueBlop<UserModel>{
    CurrentUserData(Cubit<Future<UserModel> Function()> loadUser):super(loadUser);

    @override
    Stream<Transition<BlopEvent<String>, String>> transformEvents(
        Stream<BlopEvent<String>> events,
        TransitionFunction<BlopEvent<String>, String> transitionFn,
    ) {
        return super.transformEvents(
            events.debounceTime(Duration(milliseconds: 100)),
            transitionFn,
        );
    }
}

final user = CurrentUserData(currentUserLoader);

// change loader
// emit new loader function that trigger auto reload of user
currentUserLoader.changeId(newId); 

// manual reload
// triger reload and await result
await user.reload(); 

// events can be transformed 
// debounce all event and reload only once, all futures complete on reload
user.reload();
user.reload();
user.reload();

// add ability to await state loading
// return current loaded state or await next loaded event data or error
await data.loadingFuture;


// static remote value can be only manual reloaded
class ShopList extends RemoteValueBlop<ShopModel>{
    ShopList():super.staticLoader(ShopRepositoty.load);
}

Wotk with state #

late final RemoteModel<T> state = remoteValueBlop.state;

// concrete state check
state.isInitial;
state.isLoading;
state.isError;
state.isData;

// combined state
// return true if error or data
state.isLoaded;

// if data transform from T to E, in other cases cast to RemoteModel<E>
state.transformData<E>((T v) => transform(v));// return RemoteModel<E>

// cast data to E
state.cast<E>(); // return RemoteModel<E>
  • Extend with typed event's
  • Extend with blop method
0
likes
0
pub points
1%
popularity

Publisher

unverified uploader

Package that implement remote value abstraction and add cubit to mange it.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bloc, blop, flutter, freezed_annotation, hive, massa_utils

More

Packages that depend on remote_value