Closed altmattr closed 2 years ago
I think the best way to do this might be to extend the current init method to something like
const init = (url, setup = undefined, act = undefined) => {
// usual connection / subscription
setup != undefined && setup()
return {
...
act: act == undefined ? undefined : setInterval(() => act(), 1000)
...
}
The act function can either be returned to the user to call when they want or we can just call it for them after setup.
Yes, absolutely, that is a really good idea. but I think the defaults need to be () => {}
or you will get an error
M att
On 17 Nov 2021, at 2:12 pm, cjpappas @.**@.>> wrote:
I think the best way to do this might be to extend the current init method to something like
const init = (url, setup = undefined, act = undefined) => { // usual connection / subscription setup() return { ... act: setInterval(() => act(), 1000) ... }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/cjpappas/MacSim/issues/20#issuecomment-971135206, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAMQFYIRS66IOGLTLSQC4DTUMMMTRANCNFSM5IFZ7EIA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
implemented in 3c8000958a41c72fa758eab1f4d399a4aeae9884
Add "auto" mode ability to the API. Code can either run just as it is (and any node-based code will have to work this way) or (in the browser) the programmer can just provide
setup
andact
methods and the api takes care of callingsetup
once at the start andact
once every second.