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

add examples for sendUpdate, setUpdateListener #82

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WofWca
Copy link
Contributor

@WofWca WofWca commented Jul 13, 2024

Closes #60

Some might say that the setUpdateListener example is too convoluted, but you can't really showcase the usage of serial without this much code.
Plus, a briefer example is already shown in sendUpdate() docs.
Update: I simplified the example.

The code has been tested with the webxdc-dev tool,
and (mostly) fomatted with Prettier.

@WofWca WofWca force-pushed the sendUpdate-and-setUpdateListener-examples branch 2 times, most recently from 40ac2ef to f9a7c9a Compare July 13, 2024 13:47
@hpk42
Copy link
Contributor

hpk42 commented Jul 13, 2024

thanks! the setUpdateListener example is too big -- it almost provides more of a framework where you can just implement some functions but that's not needed for a basic example.
The basic logic boils down do

process-update() 
if update.serial == update.max_serial { render()}

and i would do this without any extra function. Anything more advanced should be link to a github-repo if needed.

Closes #60

Some might say that the setUpdateListener example is too convoluted,
but you can't really showcase the usage of `serial`
without this much code.
Plus, a briefer example is already shown in `sendUpdate()` docs.

The code has been tested with the `webxdc-dev` tool,
and (mostly) fomatted with Prettier.
@WofWca WofWca force-pushed the sendUpdate-and-setUpdateListener-examples branch from f9a7c9a to 7263ac5 Compare July 14, 2024 08:53
@WofWca WofWca requested a review from hpk42 July 14, 2024 08:54
Copy link
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed i think still

src-docs/spec/setUpdateListener.md Outdated Show resolved Hide resolved
src-docs/spec/setUpdateListener.md Outdated Show resolved Hide resolved
Comment on lines +53 to +55
initialPendingUpdatesHandledPromise.then(() => {
renderDocument();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful when nobody has sent any updates yet.

src-docs/spec/setUpdateListener.md Outdated Show resolved Hide resolved
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.

Provide examples of API usage in https://docs.webxdc.org/spec.html
2 participants