Coder Social home page Coder Social logo

Comments (2)

manzt avatar manzt commented on September 21, 2024

FWIW, I think this would be a really useful feature to add to @anywidget/react (as in a new hook or extending the existing hook).

from lonboard.

batpad avatar batpad commented on September 21, 2024

@kylebarron I see what you're trying to do in #113 - yea, the debounce is not going to work defined where you have it - I think there's roughly two options here if we want to try with this approach:

  • Put the debounce where you have the callback for onViewStateChange: https://github.com/developmentseed/lonboard/pull/113/files#diff-c2f8ec75103ae661341f239c22352142d1d5e965cad55b19cfb978902500106cR77 . But you don't want to do that because you want to update the state and have a single source of truth - here I still think what we could have is a useModelState and useModelStateUnsynced or so - where calling useModelStateUnsynced just never calls the model.save_changes() method. And that should be okay? (And then be more intentional about when you call useModelState to actually sync with python). I can try sketching this out.
  • If you really want something like a useModelStateDebounced where that method "debounces" the calls to .save_changes(), you'd need to have a way within that function to store state of when the last call to .save_changes() had been made, and conditionally make that call - if this was a traditional REST API, I'd imagine one could create some queue system and be intelligent about it based on the response callback from the server, and cancel previous calls, etc. Would have to think about this, but could also potentially sketch something out.

@kylebarron do you know if this all works if you comment out the model.save_changes() line? I'll probably try and fix up your branch and give this a whirl - we should definitely be able to get this to work.

from lonboard.

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.