bettdouglas / grpc-dart-docs

A site built with docusaurus to show how the Flutter Community can use gRPC for Client & Server Side needs
https://grpc-dart-docs.pages.dev
8 stars 2 forks source link

add create, update, delete methods #2

Open idc77 opened 1 year ago

idc77 commented 1 year ago

List and Get are easy, what about Create, Update, Delete?

final createBlogsProvider = FutureProvider.family<Blog, Blog>((ref, blog) {
  final blogServiceClient = ref.read(blogServiceClientProvider);
  return blogServiceClient
      .create(CreateBlogRequest(blog: blog))
      .then((response) => response);
});

My CreateBlog has a Blog blog = 1 parameter and returns a Blog object err message.

But you know, I tried with this mason approach, and it's not my thing. 1st of all your documentation is incomplete, without this repo one wouldn't even be able to make the connection from the client to the providers. You have no support for routing, Maybe you should create a complete app 1st then a documentation site about it.

bettdouglas commented 1 year ago

That's true. Sorry I never saw this issue on time. But I'm creating a be_real like clone where users will be able to login, logout, register and do CRUD tasks like Instagram. I hope that will help.

I'll follow up on this issue when ready.

bettdouglas commented 1 year ago

Hello @idc77, I've written a basic CRUD article which you can try to follow up with on the stormberry-crud branch. Please check it out using the url below and let me if you encounter any problems with the article.

https://stormberry-crud.grpc-dart-docs.pages.dev/docs/databases/crud_with_stormberry.

I'm writing an app that will accompany it as well using riverpod. I'll let you know how it goes but for now you can use https://kreya.app to test the API.

bettdouglas commented 1 year ago

@idc77 also, I don't think creating a FutureProvider is good for tasks like this. Use a StateNotifier which will enable you to call methods which trigger state changes. Then on your UI, you watch for these state changes.

FutureProvider is good for fetching/loading things. Take a look at this example from the docs. https://docs-v2.riverpod.dev/docs/providers/notifier_provider