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.

addon API for storing state per-session or per-app.

See original GitHub issue

Issue: we removed the use of URL params for storing state. This will be an issue if apps reload (e.g. because HMR isn’t working right, see for instance https://github.com/storybooks/storybook/issues/5267).

Right now we have an adhoc way of using session/localStorage for storing things. We also have retained setQueryParams but it no longer actually affects the URL so will not survive reloads etc.

We should resolve this for v5.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
leoylicommented, Feb 7, 2019

@shilman, this is not working in the beta.1 version. (not sure about the prior versions)

For example, in a decorator I call api.setQueryParams({ test: 'abc' }). The URL is not changed and the subsequent call both (console.dir(api.getUrlState()) and console.dir(api.getQueryParam())) was not showing the query parameter I provided…

Any clue or should I open a new issue?!

1reaction
tmeasdaycommented, Jan 17, 2019

Here’s what I sketched out in my head:

What if we update setState to have the signature:

function setState(update: object, persistence: 'none' | 'session' | 'forever') {}

When we setState, we may also save a “subset” of the state into sessionStorage and localStorage based on the above.

When we initialize the state, we will combine:

  1. The default initial state returned by each module
  2. The forever state
  3. The session state

Merging them with preference in that order (i.e. session > forever > defaults)

Read more comments on GitHub >

github_iconTop Results From Across the Web

addon API for storing state per-session or per-app. · Issue #5271
Issue: we removed the use of URL params for storing state. This will be an issue if apps reload (e.g. because HMR isn't...
Read more >
WCF: Using Transactions to Manage State and Error Recovery
Between transactions, the service should store its state in a resource manager. At the beginning of each transaction, the service should retrieve its...
Read more >
Stores: Making State Global Without React's Context API
In this article we're going to explore some drawbacks of context-based state in typical application architecture, then explore an ...
Read more >
Saved State module for ViewModel - Android Developers
For state that is used in business logic, hold it in a ViewModel and save it using SavedStateHandle . For state that is...
Read more >
React Context for dependency injection not state management
Dive into the concept that React Context API is primarily a tool for ... Technically, Context allows storing a value, reading a value, ......
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