GithubHelp home page GithubHelp logo

Comments (9)

quisido avatar quisido commented on May 19, 2024 3

I have released [email protected] to include this functionality as addCallback. The documentation for addCallback has been added to the README.

I added some unit tests and manual app testing to try to insure there were no breaking changes, but this version included a major change to some internal workings. I would love some community feedback on if any errors are discovered.

Thank you for your patience. I'm sorry about the long delay. I have been unable to contribute for the past month, but I'm hoping to begin knocking out a lot of ReactN's open issues now.

from reactn.

quisido avatar quisido commented on May 19, 2024 1

I understand. You want persistence of state between application launches.

I think "afterware" support may allow for this. Something like useAfterware(functionThatReceivesStateOnChange) will allow custom functionality, like writing to storage when the state changes.

useAfterware(function(global) {
  persistentStorage.set('global', JSON.stringify(global));
});
// The above function executes with the new global state whenever setGlobal occurs.

If something like this sounds good to you, I'll mark it as TODO. I want to make sure it matches your use case.

from reactn.

quisido avatar quisido commented on May 19, 2024 1

This has not been done yet. I have been out for various reasons the past month and have returned to my development life as of today.

from reactn.

quisido avatar quisido commented on May 19, 2024

Are you talking about for SSR? Can you elaborate on how you want state to persist and how you would want it to rehydrate?

from reactn.

quisido avatar quisido commented on May 19, 2024

I'm changing this to just a request for state persistence, as rehydration between server and client exists as issue #9.

I would still need more information to tackle this request, though. I'm not sure what specifically you are requesting in relation to a React Native application.

from reactn.

rotoxl avatar rotoxl commented on May 19, 2024

Hi! sorry for the delay. My request was not about server side rendering, it was about persistence and (after cold start) retrieving that data from storage (the term rehydration means that in redux persistence - https://github.com/rt2zz/redux-persist). It just handles the 'asynchronicity' of a cold start to initialize the store with the latest bunch of data, IIUC

from reactn.

rotoxl avatar rotoxl commented on May 19, 2024

Yes, I think that would cover the lifecycle of any mobile app (which usually follow an offline-first approach).

Used in conjunction with componentDidMount (pseudo code):

//based in the example from reactn/Examples/Class Components
export default class MyView extends React.Component {
 ...
  componentDidMount() {
     persistentStorage.get('global', (value)=>{
         this.setGlobal(
                  JSON.parse(value)
         )
     })
  }

  render() {
    ...
}

Thanks for your work.

from reactn.

darbio avatar darbio commented on May 19, 2024

Was this implemented? Is there a way to hook into setGlobal with the current release?

from reactn.

quisido avatar quisido commented on May 19, 2024

I'd just like to state that I have this existing in my local repository (using the name addCallback), but it's pretty important to me that I get unit tests completed for the project as a whole before cutting a new version, so I do not have an ETA on release. I may do an alpha release if the unit tests delay this too much.

from reactn.

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.