filer icon indicating copy to clipboard operation
filer copied to clipboard

Evaluate our use of lib/intercom.js, lib/eventemitter.js

Open humphd opened this issue 6 years ago • 3 comments

The intercom.js project has been dead for a while. We've got a small version of it in lib/intercom.js, which we use to create filesystem watches across windows.

I suspect there are more modern ways to do this, which we can either build or use via a dep. Let's see if we can update this.

humphd avatar Nov 27 '18 18:11 humphd

I worked on this a bit tonight, trying to remove https://github.com/filerjs/filer/blob/master/lib/eventemitter.js and instead use a bundled/node.js EventEmitter via Parcel. I got stuck because it requires surgery to intercom.js. Probably doing both as part of the same bug makes sense.

humphd avatar Nov 28 '18 03:11 humphd

https://github.com/pubkey/broadcast-channel might be a better solution here.

humphd avatar Nov 28 '18 03:11 humphd

BroadcastChannels are available in Chrome and Firefox, but not in Edge or Safari (yet), see https://caniuse.com/#feat=broadcastchannel.

We'd have to polyfill for a while to make this work. I think that's probably OK, since the polyfill does exactly what intercom is doing now: use localStorage events.

humphd avatar Nov 28 '18 17:11 humphd