question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Proposal] Lazy models

See original GitHub issue

The addModel and removeModel API doesn’t feel as integrated as the rest of the APIs. This proposal will detail an inline approach of declaring your code-split/lazy-loaded models.

Details coming soon.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
allprocommented, Oct 15, 2020

It would be great if EP could handle nested/name-spaced models. In my current project we have over a hundred models. To make this scale manageable, every model is categorized by a namespace, like devices.groups, devices.freeze, devices.data, devices.geoFence, devices.data, devices.dataPoints, etc.

I’d like to be able to dynamically add models because some product features are user-specific, but currently it’s impossible because EP cannot handle adding a model with a nested path. I have mentioned this before but it wasn’t considered a priority then. However if working on updating the dynamic model handling, please consider handling ‘model paths’ like devices.groups in addition to simple model names in the root of the store.

1reaction
kamikazePTcommented, Oct 8, 2020

@ctrlplusb

The only thing I dont like that much about that approach is that you are still obligated to know at the root level about the entire app state model

I would like to be able to further down the react tree be able to mount/unmount slices of state

what about this?

import { lazy } from 'easy-peasy';
const ProductsModel = lazy(() => import('./models/products'))

// and then

function ProductsSection() {
  return (
    <ProductsModel>
      <ProductsList />
    </ProductsModel>
  )
}

// or

function ProductsSection() {
  return (
    <ProductsModel keepMounted>
      <ProductsList />
    </ProductsModel>
  )
}

the flag keepMounted would keep the state model even if it was unmounted, otherwise it would wipe and re-create on mount/unmount of ProductsSection

EDIT: But now the lazy call seems worthless, my initial draft was something like

import { Store } from 'easy-peasy'
import model from './model'

function ProductsSection() {
  return (
    <Store.Model model={model}>
      <ProductsList />
    </Store.Model>
  )
}

// or

function ProductsSection() {
  return (
    <Store.Model model={model} keepMounted>
      <ProductsList />
    </Store.Model>
  )
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic Proposal Evaluator: A Lazy Learning Strategy Toward ...
In this paper, we propose a lazy learning strategy to train the GPE, which aims to blindly estimate the quality of each proposal...
Read more >
proposal for lazy foreignkeys - Google Groups
Hi all, I've seen some level of interest in the idea of a lazy foreign key (one whose target table is determined by...
Read more >
Lazy Consensus - Apache OpenOffice
The key thing about lazy consensus is that it's easier for people to agree, by doing nothing, than it is to object, which...
Read more >
P1194: The Compromise Executors Proposal - open-std.org
In the interest of maintaining feature parity with P0443 while also adding support for a lazy asynchronous execution model, we suggest the ...
Read more >
Pete Davidson's LAZY Wedding Proposal To Ariana Grande ...
For more entertainment news:https://www.youtube.com/watch?v=ANjiLgWRWqg&t=1sPete Davidson Is Convinced Ariana Grande Will Dump him and he ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found