Code Monkey home page Code Monkey logo

Comments (10)

jaumard avatar jaumard commented on June 16, 2024

This one is quite blocking me right now because I'm using valueObservable.value to pass the current value between blocs to initialized the next bloc for example. Now I can't do that anymore because I have a Stream instead

from built_bloc.

rrousselGit avatar rrousselGit commented on June 16, 2024

I'm personally against it
I purposefully expose only stream/sink for my blocs

I have a library in wip that removes the need to set initialData on stream builder.

If you're interested I can give you a preview

from built_bloc.

jaumard avatar jaumard commented on June 16, 2024

I'm generally don't use it for initialData on stream builder. But instead I'm doing for example:

void _processCardTransaction() {
    final appBloc = Provider.of<AppBloc>(context);
    final prefsBloc = Provider.of<PreferencesBloc>(context);
    _bloc.startPayment.add(CheckoutCardInfo(
      widget.amount,
      widget.isMsi,
      appBloc.currency.value,
      prefsBloc.donglePrefs.value.mode,
      prefsBloc.donglePrefs.value.device,
    ));
  }

I know those values will not change at any time during this screen and the bloc is local to the screen. I personnally don't want to listen 2 more streams for nothing... I just access the data directly

from built_bloc.

jaumard avatar jaumard commented on June 16, 2024

I understand your point a view to only expose stream/sink, maybe having both possibilities will make everyone happy ^^

from built_bloc.

rrousselGit avatar rrousselGit commented on June 16, 2024

I know those values will not change at any time during this screen and the bloc is local to the screen. I personnally don't want to listen 2 more streams for nothing... I just access the data directly

Does that really makes sense to use a stream then?

from built_bloc.

jaumard avatar jaumard commented on June 16, 2024

If I was only using them like this it's true that I don't need stream, but in some places I use them as stream (if multiple bloc are in multiple screen, in that case I use them as stream and not values).
Maybe we can have like @rxstream to expose rx types and @stream stay unchanged :)

Also some people pass a bloc into another as a dependency injection and listen or chain streams inside the constructor, in that case it's more convenient to have rx types than just raw stream. I don't do that but already see it.

from built_bloc.

aloisdeniel avatar aloisdeniel commented on June 16, 2024

Don't like the idea of exposing rx types a lot since blocs should be framework agnostic to me and only expose streams and sink, like @rrousselGit said.

Couldn't your action be asynchronous ?

You could then use await stream.first to access values.

I know it is not ideal, but it fits better with the pattern to me.

I prefer having services injected into my Blocs for such data.

from built_bloc.

jaumard avatar jaumard commented on June 16, 2024

await stream.first doesn't cover all cases, example currency.value will return me null is there nothing on my stream where await stream.first will just wait forever ^^

from built_bloc.

rrousselGit avatar rrousselGit commented on June 16, 2024

using .value is evil. It works only because Dart is single threaded.
You'd have a lot of concurrency issues otherwise

from built_bloc.

jaumard avatar jaumard commented on June 16, 2024

I know ^^ but I also know that Dart is single threaded so I'm safe :D I'm just taking advantage of the langage

from built_bloc.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.