-
Notifications
You must be signed in to change notification settings - Fork 32
self should be Window or ServiceWorker. #67
Comments
I would probably do something like: |
Good thinking, perhaps we could do the following: let [<Obsolete("Use self_window")>][<Global>] self : Window = jsNative
let [<Global>] self_window: Window = jsNative
let [<Global>] self_web_worker : Worker = jsNative
let [<Global>] self_service_worker : ServiceWorker = jsNative |
I never used |
@nojaf Thank you :) @whitetigle Didn't you work with service worker on a project ? |
TBH I didn't know The proposal looks good, although there may be a couple of points to consider:
AFAIK the current expert of service workers with Fable is @Nhowka ;) Maybe he also has some ideas on how to improve the API? |
How do they decide what's the correct |
There is more returns for
The only To be fair my opinion is more radical. Keep the current |
Ok, sounds good. So we would have something like |
@MangelMaxime Yes but I did not migrate my service worker code to f# yet. So no problem with I'm too in favor for some specialized package. |
@whitetigle Oh ok :) |
@alfonsogarciacaro I believe this is how TypeScript does it. |
@nojaf We could be less aggressive and just add a new module for each one, shadowing I was planning on skipping the bindings entirely and doing a library exposing the service worker common uses via JavaScript files but if you can add the bindings even better. |
Could you give an example how the shadowing would work? I don't know what happens when two module expose the same member. Last one wins? |
Thanks for the links @nojaf
Yes, last module opened wins. That's why some Option methods are shadowed when opening Maybe this is an opportunity to clean the Browser (and Core JS) bindings. They were originated from an early Typescript declaration and then it was edited manually over the time. It'd be nice to separate WebWorker and other bindings into their own packages. This could benefit the REPL as Fable.Import.Browser.dll is quite big to download (although I don't know how much space we'll be able to save if any). I guess we could try running the latest Typescript DOM declarations with ts2fable, overwrite the current bindings and check the diff. But we need to be careful not to overwrite some of the manual changes (e.g. most event calls return a generic now in the bindings so you can just return unit instead of an object). Is there any volunteer for this? 😸 |
The last time I tried to add just the Now maybe the tooling is efficient enough for me to try again, but no promises. |
I'll try to make some time for this as well. |
Awesome, thank you @nojaf. Please let me know if you need any help. |
Hmm ran dom.ts throught the latest version of ts2fable. Maybe extracting Worker stuff from the Browser module is a safer approach. |
Was the file generated with an earlier version of |
Hmm true, but many bugs would have been fixed since that release right?
|
Yeah, the file was generated with a very early version (also early version of the ts declaration) and there have been many manual tweaks since, so auto merging is going to be difficult :/ Your approach makes sense to me @nojaf. Removing should be easier. If it doesn't take too long it'd be also a good opportunity to remove old APIs like IE-only stuff. |
As a side note, I need to check but an advantage of using newest ts2fable and dom.ts would be to add more comment documentation to the APIs. We don't have that many at the moment. But we need to find a way to make it easier to see the diffing. I'll investigate, maybe writing a script to sort interfaces and members within the interface alphabetically. |
I'm playing around with ServiceWorkers and self is limited to the Window class.
addEventListener_install
doesn't work without the cast.Is not always true.
I'd like to send a PR, how should we solve this? Erased Union Type that capture both Window and ServiceWorker?
The text was updated successfully, but these errors were encountered: