felangel / bloc.js

A predictable state management library that helps implement the BLoC design pattern in JavaScript
https://bloclibrary.dev
189 stars 22 forks source link

SSR state hydration #5

Closed tim-smart closed 4 years ago

tim-smart commented 4 years ago

Thanks for doing a Javascript fork! Had a crack at it myself (https://github.com/tim-smart/bloc-js) but would be great to switch to a project that has a bigger community behind it (and I don't want to maintain it lol).

It would be awesome if you could support state hydration with this library, as it would help with creating apps that make use of Server-Side-Rendering. This is a non-issue with Flutter obviously, which will probably mean a different API to the Dart equivalent.

Here is a Next.js example https://github.com/tim-smart/nextjs-bloc-js-example

Let me know what you think!

felangel commented 4 years ago

Hi @tim-smart 👋 Thanks for opening an issue!

I think it's a great idea 👍I'm currently focusing on several issues in the Dart Bloc repo but if you have some time and are willing to open a PR that would be awesome 😄

If not, I'll probably get to this sometime next week because I also have to update the bloc.js API to align with the new 1.0.0 changes in the Dart Bloc API. Let me know if you're able to contribute and thanks for bringing this up! 💯

Edit: I took a look at your repo and if you'd be willing, it would be amazing if you could join as a collaborator and help with the bloc.js development. I could really use the help especially seeing as you have react and vue packages!

tim-smart commented 4 years ago

I have made changes the way my project works - quite different to before. No longer using a stream of events to cut down on boilerplate and simplify the API.

So I'm going to close this!

Tokenyet commented 4 years ago

Hey, A lover of flutter and bloc here! Want to share some experience with this project. This project is working as expected, but need some React.Context API to be worked as BlocProvider. It's all fine with SPA, but when I used Nextjs + Bloc.js, and what some SSR feature. Bloc became a bad monster, because the page should be rendered on server, to pass to client, Bloc has no way to sync data :( There is such a obstacle I experienced.

By the way, I still love to use bloc with flutter, and maybe SPA. But for Nextjs(SSR), I think I should go traditional redux way, the idea of store is easy for syncing data on client and server, even If I hate the flow of redux 😝