GithubHelp home page GithubHelp logo

Comments (5)

rrousselGit avatar rrousselGit commented on May 28, 2024 1

This is expected. The ProviderSubscription was already closed my Riverpod by the time you called .read()

Riverpod closes all subscriptions associated to a widget when the widget is unmounted. So you cannot use sub.read() after the widget got unmounted – which is what you do here.

from riverpod.

rrousselGit avatar rrousselGit commented on May 28, 2024 1

Sounds like you used Future to cheat around the error. That wasn't really supported

Looks like Consumer supports calling sub.read inside ConsumerState.dispose. Sounds like we would want to support this for useEffect.
Do you mind opening a feature request for this?

from riverpod.

a1573595 avatar a1573595 commented on May 28, 2024

This is expected. The ProviderSubscription was already closed my Riverpod by the time you called .read()

Riverpod closes all subscriptions associated to a widget when the widget is unmounted. So you cannot use sub.read() after the widget got unmounted – which is what you do here.

So there is currently no other solution to cache data?

I hope not to load all the DataSource at once when entering NextPage, and release the KeepAliveLink of DataSource after leaving NextPage.

from riverpod.

rrousselGit avatar rrousselGit commented on May 28, 2024

The issue is likely your Future wrapping the .read()

I guess removing it should work

from riverpod.

a1573595 avatar a1573595 commented on May 28, 2024

The issue is likely your Future wrapping the .read()

I guess removing it should work

I thought so before, but actually it's not.

Removing the future wrapping throws an error:

  • 2.5.1:Bad state: called ProviderSubscription.read on a subscription that was closed.
  • 2.4.10:At least listener of the StateNotifier Instance of 'StateController' threw an exception
    when the notifier tried to update its state.

Having a Future throws an error:

  • 2.5.1:Bad state: called ProviderSubscription.read on a subscription that was closed.
  • 2.4.10:Work well.

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.