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.

feat(query): clearing data after unset listener

See original GitHub issue

Do you want to request a feature or report a bug?
bug

What is the current behavior? If i want to change a document listener to another id, then previous data is still existing until new data is received.

What is the expected behavior? After removing the listener, the data connected to that listener should be removed.

Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups? Newest

Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

[
    {
        collection: 'collections',
        doc: props.collectionId,  // data from my reducer. If this id is changed then previous data is still existing
        storeAs: 'collection'
    }
]

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
esbenvbcommented, Apr 28, 2019

I agree with @apietrzak - of course we can store the data with a custom-made key for each document, but that will not only make the app a bit code more complex, it also leads to memory leaks, when the user is browsing around in 100s or 1000s of pages in the app, all these are kept in the store, because they were once loaded.

I don’t see any solutions that are more elegant than the removeOnUnset: true option suggested.

2reactions
apietrzakcommented, Nov 12, 2018

@prescottprue I understand it, but still, i don’t need that data in the store if a listener was removed. For example: A user iterates over 100 collections, then it’s taking 100 entries in the store.

Listener config:
[
    {
        collection: 'collections',
        doc: props.collectionId,
    }
]

State:
collections: {
    collectionID1: {...}
}

Actions:
UNSET_LISTENER
SET_LISTENER
LISTENER_RESPONSE

New state:
collections: {
   collectionID1: {...},   // I don't need that
   collectionID2: {...}
}

Additionaly, when the user backs to the first collection then in the store is still old data and will be refreshed soon, which means the user will see old view of my appliaction instead of loading screen. In my case, there will be better to remove that data and load it one more time if needed. For example by adding argument to listener config:

[
   {
        collection: 'collections',
        doc: props.collectionId,
        removeOnUnset: true
   }
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Event listener for when element becomes visible?
Is there a way i can put an event listener on my toolbar to listen for when it becomes visible so it can...
Read more >
MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables
The MySQL server maintains many system variables that configure its operation. Each system variable has a default value. System variables can be set...
Read more >
sanity-io/client - GitHub
Deleting an element from an array. Each entry in the unset array can be either an attribute or a JSON path. In this...
Read more >
Go Fiber by Examples: Delving into built-in functions
After executing, a new Fiber instance will be created in the app variable with ... handler) // Create a new route with DELETE...
Read more >
Connecting Firebase to a Contact Form - YouTube
In this video we will take the responsive contact form we built in the last video and hook it up to a firebase...
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