Coder Social home page Coder Social logo

Comments (6)

rrousselGit avatar rrousselGit commented on August 21, 2024

Why are you overriding "name" as "emphasis"?

from riverpod.

jimmy-robert avatar jimmy-robert commented on August 21, 2024

Why not? 🙂 It is just a simple example here, but there can be cases where I want to override a behavior to add some features but still calling the original provider (e.g: modify a real HTTP response, transform a value, ...).

I think I would use this for mocks but it can still be used for real use cases I guess.

from riverpod.

rrousselGit avatar rrousselGit commented on August 21, 2024

For sure. I'm just trying to understand the use-case as much as possible.
To make sure that there isn't a different solution that we could take

from riverpod.

rrousselGit avatar rrousselGit commented on August 21, 2024

Note that you could do it with two providers:

final provider = Provider((ref) => 'Foo');
final originalProvider = Provider((ref) => ref.read(provider).value);

So when you override provider, originalProvider is still not overriden

ProviderScope(
  overrides: [
    provider.overrideAs(Provider((ref) {
      final original = ref.read(originalProvider).value;
      return 'Hello $original';
   }),
  ],
  child: // 
)

from riverpod.

tbm98 avatar tbm98 commented on August 21, 2024

I think use-case of overrideAs is for testing and both of them should be unrelated to each other.

from riverpod.

rrousselGit avatar rrousselGit commented on August 21, 2024

Closing for now as I don't think this is truly needed since there are other solutions, and implementing that would decrease overall performances.

from riverpod.

Related Issues (20)

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.