Open kenchris opened 8 years ago
Looks good, it's mostly syntactic sugar. Your method is complementing events but AFAICT is not replacing them. What is the callback dispatching mechanism? We need support from the main loop. What idioms are better known by developers? Events at least are pretty well known.
They should be called async on the object itself (so it becomes
I like that you naturally keep the relevant code together and this method might be popularized with custom elements and node.js libraries like noble.
Instead of
and handling all sensors inside each method, wouldn't it not be better to give it an object instead, like Bleno does with Characteristics. That also allows you to easily share objects/value for each sensor instead of relying on global variables. And it allows you to inherit from common objects when they are very similar in spirit.
pseudocode (ignore naming) [the *Callback methods are modelled after latest ES6 compatible Custom Elements spec]: