Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-hooks version of riverpod #12

Closed
chimon2000 opened this issue Aug 27, 2020 · 5 comments · Fixed by #27, #28, #29 or #31
Closed

Support non-hooks version of riverpod #12

chimon2000 opened this issue Aug 27, 2020 · 5 comments · Fixed by #27, #28, #29 or #31

Comments

@chimon2000
Copy link

I would like to request support for the non-hooks version of riverpod, as detailed on the landing page. Here is a rough draft of how I'd expect it to look:

final counterProvider = BlocProvider((ref) {
  return Counter();
});

class Counter extends Cubit<int> {
  Counter(): super(0);

  void increment() => emit(state++);
}

class Home extends ConsumerWidget {
  @override
  Widget build(BuildContext context, ScopedReader watch) {
    final count = watch(countProvider.state);
    return Text('$count');
  }
}

If this is currently supported, I didn't see any mention in the existing documentation.

@kranfix
Copy link
Owner

kranfix commented Aug 27, 2020

Hello. I am working exactly on it. In few hours I will be publishing the draft of the API and what problems I am trying to revolve resolve.

I started with flutter_hooks_bloc first because I needed to have a laboratory to experiment with bloc and hooks to have it as an input for the riverbloc api.

@chimon2000
Copy link
Author

Awesome, looking forward to playing with the API!

@kranfix
Copy link
Owner

kranfix commented Aug 30, 2020

@chimon2000 sorry for delay. Rivebloc is alive! https://pub.dev/packages/riverbloc

@chimon2000
Copy link
Author

@kranfix finally got around to playing with this and it works like a charm.

A minor nit:

Should add docs for usage with Consumer/ConsumerWidget and read vs. watch. I know that this is specific to riverpod, but it would be useful, especially with links back to riverpod explaining how those things work.

@kranfix
Copy link
Owner

kranfix commented Sep 2, 2020

The riverbloc pacakage is published and the docs will be added soon and it was moved to #22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants