River_pod: Adding the lazy attribute allows the provider to disable the lazy load feature.

Created on 19 Aug 2020  路  4Comments  路  Source: rrousselGit/river_pod

The current provider only instantiates when used. but there are a few cases where I want it to be initialized before use, like lazy: false.

enhancement

Most helpful comment

The lazy parameter is simple impossible to implement for numerous technical reasons.

So the approach mentioned by @smiLLe and @mono0926 is the best

All 4 comments

Mhhh but you can basically do
``dart runApp(ProviderScope(child: HookBuilder(builder: (context) { useProvider(provider); return MyApp(); }))));

Consumer version:

runApp(
  ProviderScope(
    child: Consumer(
      (context, watch) {
        watch(provider);
        return MyApp();
      },
    ),
  ),
);

The lazy parameter is simple impossible to implement for numerous technical reasons.

So the approach mentioned by @smiLLe and @mono0926 is the best

Yep. 馃槄

Was this page helpful?
0 / 5 - 0 ratings