Open timpur opened 6 years ago
Hi there! I haven't worked on this project in a long while, but I'm always open to talk. I'm not sure that an event loop model would work well on embedded systems like Arduino. You need a kernel to send signals to your process and schedule it when work is available. I'm not sure that there is a comparable thing in an embedded device. Admittedly my knowledge of Arduino is only at a hobbyist level, so I could be entirely wrong.
You may also want to check out rili, it is basically liblw
but people are actually working on it. :)
Looked at rili
lib and think its complex to port to arduino, but i think bits from this lib can be ported and tweaked to work for arduino. wondering if your willing to work with? Would be nice to get some expert knowledge , as you did design this lib :P.
Also think and event loop model would work alright on arduino, but do we need it? Promise is just an interface, right? does it really need to hooked into the event loop ?
If you would like to fully implement the Promises/A+ spec then you do need an event loop. According to spec the executor (the function passed to new Promise
) must be executed synchronously, but the next function (the one passed to .then
) must not be executed until the next tick of the loop. This guarantees consistency even when the executor happens to call resolve
or reject
synchronously. For example, both of these execute the same:
(new Promise((resolve) => {
console.log('first')
resolve()
})).then(() => console.log('third'))
console.log('second')
// ----------------------------
(new Promise((resolve) => {
console.log('first')
setImmediate(resolve)
})).then(() => console.log('third'))
console.log('second')
Though, I suppose you could have a queue of functions that you iterate over and call at the start of Arduino's loop
method. You would have to implement all the dispatching as polling. Damn, now you've intrigued me. :)
HEHEH, come on, lets do it :P ive also got bblanchon
from https://github.com/bblanchon/ArduinoJson intrigued :P We can do this.
I think we could even use an event loop (striped down).
Also i want to add some more async programing styles like Events (Event Emitter), Tasks, Timeouts, maybe observables, still thinking about things though
I don't have a lot of spare bandwidth between work and my own super secret project, but I'd be down to offer advice and some code when I can. Send me a link to the repo once you've got it started and I'll try to help.
In the same boat, thank you :) anything is greatly appreciated. Will do when I get it set up :)
Hi, I'm trying to create a lib for Async style Programing for Arduino. Wondering if you'd be okay for me to pull some ideas from this lib / if you wanted to work with me on this. You have much more knowledge and I'd like to ask for your opinions...
Would be awesome to talk to you, thanks