Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable service worker #757

Merged
merged 3 commits into from
Aug 22, 2022
Merged

Conversation

maxence-charriere
Copy link
Owner

Summary

  • App worker template can now be changed from HTTP handler
  • App worker template is now exported under the DefaultAppWorkerJS variable.

@maxence-charriere
Copy link
Owner Author

@oderwat is that provides what you need?

@oderwat
Copy link
Sponsor Contributor

oderwat commented Aug 21, 2022

Yes, it should. I need to recover an old branch and try it (we are currently on hold about push notifications because of the iPhone situation, but that seems to resolve this year).

@maxence-charriere
Copy link
Owner Author

maxence-charriere commented Aug 21, 2022

@oderwat Is there anything else you would need to consider go-app for a production candidate ?
I kind of want to release the next version.

@oderwat
Copy link
Sponsor Contributor

oderwat commented Aug 21, 2022

@maxence-charriere I am pleased with the v9.6.0 branch and have few left to wish for in general.

You could think about deprecating app.If()+related, though. I did not check if you added a warning about the (prominent but easy to forget) evaluation and told the user they might want to use an anonymous function instead.

An idea for a useful extension was adding a "debouncer" in the update chain. I thought of delaying updating after a given count of frames (or a time but then in the next frame) without updates. This would be like preventing the update but putting it in a queue and resolving it as soon as there were no more updates for that given number of frames. In that context, I also wondered if getting a frame counter from the app would be possible. I have places where I delay something using time where I really just want to wait after the next update.

The other extension I would love is basically the same as PR #562. I think that functionality could remove the need for globals. Currently, we are using Twirp for creating frontend/backend communications. To make the client available to all the components that use it, I have different ways: A global variable in a special package (global), adding components from the root and initializing them (for components from different repositories), or even just grabbing the page URL and doing a full client implementation in the component (wasting resources). To get the initial client setup and bind them with the start of the root component, I need to transfer some information from the place where I set up the route with the component (type) to the actual creation of that component. For example, I can switch between JSON and Protubuf messages by a CLI flag. That flag is already transferred over the "app.Env." The instantiated client is then transferred using a global variable. This could be cleaner when the route would call a factory function, which could use a closure to add parameters. This factory function then emits the actual component instance and could initialize something like the API client and even add other shared functionality. I do not like using the messages + state observers for that, as they are typeless and async, making the setup harder to handle and understand.

But, as I said above, I am happy with v9.6.0 already.

@maxence-charriere maxence-charriere merged commit 16022ef into v9.6.0 Aug 22, 2022
@maxence-charriere maxence-charriere deleted the customizable-service-worker branch August 22, 2022 05:10
maxence-charriere added a commit that referenced this pull request Aug 22, 2022
* Go 1.18 and custom elements (#739)

* rename html generated files

* bump required go version to 1.18

* update dependencies

* rename attributes() to getAttributes()

* rename Mounted() to IsMounted()

* bump go version in ci

* rename dispatcher() to getDispatcher()

* rename children() to getChildren

* rename context() to getContext

* rename parent() to getParent()

* Create html.go

* createElement now also takes namespace

* html element mount

* move html attribute logic

* change replace logi

* add js value delete and equal

* html element update

* attributes unit tests

* html element implementation complete

* event handler unit tests

* fix wasm test

* fix unit tests

* fix test 2

* Update state_test.go

* benchmark element

* generate html

* Revert "generate html"

This reverts commit bcb4414.

* rename element.selfClosing

* rename element.parentElem

* rename elem.disp

* rename elem.jsvalue

* use attributes in element

* elem uses eventHandlers

* change getAttributes and getEventHandlers return values

* refactor elem mount/dismount

* refactor element update

* refactor element remove child at

* cleanup element

* move element.go to html.go

* add on method to html elements

* fix gen typo

* replace interface{} by any

* update deps

* customizable element contructor and test

* bump go version doc to 1.18

* cleanup

* cleanup

* optimize html convert

* rename customizable by elem

* Revert "rename customizable by elem"

This reverts commit 613e0b8.

* Revert "Revert "rename customizable by elem""

This reverts commit da43f0d.

* Revert "optimize html convert"

This reverts commit 77cb2b3.

* Revert "Revert "optimize html convert""

This reverts commit ec0bfc4.

* better html write optimization

* rename SelfClosingElem to ElemSelfClosing

* generate docs

* Update attribute.go

* Update app.wasm

* revert Mounted name change

* generate doc

* fix format typo

* Update attribute.go

* optimize filter ui (#736)

* cleanup

* cleanup code

* Update html.go

* Update component.go

* Fix for attr names "accept-charset" and "http-equiv" (#748)

* Fixing invalid double set charset meta headers (#750)

* Refactor component events (#751)

* add onLifecyleEvent to UI interface

* refactor app update

* refactor app install change

* refactor resize

* refactor nav

* rename onLifecycleEvent to onComponentEvent

* Refactor engine (#752)

* enginex dispatcher implementation

* fix tests

* engineX client/server dispatcher

* enginex cleanup

* frame backoff

* init and start once

* use engine x

* rename enginex to engine + unit tests

* try preventComponentUpdate

* Update component.go

* add remove component update

* Revert "add remove component update"

This reverts commit 185f470.

* context prevent update

* allow prevent update override

* limit frame backoff

* Wasm download progress (#754)

* display download progress

* inititalize progress

* Update shell.go

* Revert "Update shell.go"

This reverts commit 99625f5.

* Update component.go

* fix unit test

* Update component.go

* V9.6 fixes (#755)

* call on component update after root update

* no emit when handling js event

* test ordering updates

* reverse update order

* avoid updating multiple time a component

* no panic when mounting mounted element

* remove ordering

* simplify

* restore mount guard

* Update component.go

* Update engine.go

* Update engine.go

* Update component.go

* Update component.go

* try fix

* Update engine.go

* try update optimization

* optimize update

* use emit back in js event

* cleanlup

* Improve loader (#756)

* Customize loading label

* Allow to custom http header to guess wasm size

* Update http.go

* fix loading header

* update loading

* Customizable service worker (#757)

* export appworkerjs template

* allow http handler to change app worker template

* fix wasm tests

* Update static-resources.md

Co-authored-by: Hans Raaf <hara@oderwat.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants