Giter VIP home page Giter VIP logo

Comments (7)

armansito avatar armansito commented on August 11, 2024

No, not terrible. Keep in mind though that not having a cache means that accessing a characteristic value might result in many read requests to the same characteristic if multiple web apps want to access it. For characteristics whose value is known not to change frequently, the cached value has the advantage of avoiding an actually over-the-air request (and battery drain).

So, this is something to consider. If a value has been read, I see no harm in caching it and most platform implementations already provide a cached value. So, why not just make it accessible through the API?

from web-bluetooth.

jyasskin avatar jyasskin commented on August 11, 2024

Saving redundant reads across web apps sounds maybe-useful. (But how often will multiple apps be asking for the same value at similar times?) Do applications need to know how old the cached value is in order to use this? Would it make sense to have the application specify a maximum age for a cached value in the read() call, and then we could have a uniform interface for cached and uncached data? I think I'd still be inclined to wait for V2 for that.

from web-bluetooth.

armansito avatar armansito commented on August 11, 2024

Oh no, I wouldn't go that far at all (i.e. bother with a maximum age or anything). The way most APIs do this is to just provide the most recently read or notified value. Based on the profile, if an app knows that this value won't change (or will be notified when it does change), then they can just refer to the cached value.

For example, several apps might be interested in knowing the current battery level. The battery-level characteristic has both "read" and "notify" properties, so the app can just enable notifications from the characteristic and wait for the next update, but then also set up its initial state based on the cached value instead of sending out a read request.

And you have characteristics which may contain just long strings that won't really change frequently, so a cached value would be useful there as well.

So, there is definitely value in providing the cached value and most native APIs already support it. I don't have a strong opinion on this, so I'd let others weigh in as well.

from web-bluetooth.

jracle avatar jracle commented on August 11, 2024

I'll just comment briefly as @armansito asks for others to reply on that issue, that I'm 100% aligned with his comments. We should keep cached value for the reasons he gives in his last reply.

from web-bluetooth.

jyasskin avatar jyasskin commented on August 11, 2024

'k. @ehsan or @marcoscaceres, I'm leaning toward keeping value. Speak up if you still want to kill it.

from web-bluetooth.

marcoscaceres avatar marcoscaceres commented on August 11, 2024

(will take a look in a day or two, currently triaging a week of unread email!)

from web-bluetooth.

marcoscaceres avatar marcoscaceres commented on August 11, 2024

I think what @armansito is describing is essentially correct. Apart from first read, generally these values could be cached. Keep it for now and we can see how we go.

from web-bluetooth.

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.