-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: add basic support for ListSignal #2775
Conversation
This changes the way updates are sent to the clients after the acceptance/rejection of an event on the server. With this applied, the REJECT event is removed and SNAPSHOT event containing the current state of the server-side signal only when (re)subscribing to a signal and not after each update. The events received by the server regarding each update to a signal is propagated to the clients with a boolean value that indicates the acceptance/rejection of the operation so clients decide to discard/apply/confirm the operation on their local value. This unifies the way with how List signals are going to work: to get snapshot events with the current state on the server only when subscribing signals (which can be a long list of values), and then getting updates of individual operations for subsequent updates, one at a time.
This extract the Signal abstraction out of ValueSignal so that the ListSignal implementation can inherit the common functionalities. Part of #2654
…ctor/extract-signal-abstraction
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2775 +/- ##
==========================================
+ Coverage 92.28% 92.49% +0.20%
==========================================
Files 81 83 +2
Lines 2683 2771 +88
Branches 688 717 +29
==========================================
+ Hits 2476 2563 +87
Misses 156 156
- Partials 51 52 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Also add some tests for ListSignal.ts
… taefi/feat/add-list-signal
|
This ticket/PR has been released with Hilla 24.6.0.alpha1 and is also targeting the upcoming stable 24.6.0 version. |
Description
This add the basic support for
ListSignal<T>
to be exposed in Java@BrowserCallable
annotated services, and to be consumed in client code to do the following operations:insertLast
remove
Note that, each item in a
ListSignal<T>
is aValueSignal<T>
, that means you can change each individaal value and the changes would be propagated to all the clients subscribed to that ListSignal and its internal ValueSignals.Fixes #2654
Aiming for the smaller PRs, the generator support for ListSignal type will be added in the subsequent PRs.
In the meantime, to use a service method that exposes a ListSignal instance, a manual step is needed for adding a TS service that acts instead of the "yet to be generated service".
As an example, having a service in Java like this:
you need to manually add the following code to utilize the backend ListSignal:
(assume you store the following TS service in
Frontend/temp/ChatService.ts
)then in your
chat.tsx
, you use it like this:I skipped demonstrating the usage of
remove
operation for brevity, but since it accepts a instance ofValueSignal<T>
, it is clear thatchatChannel.value[i]
can be passed to it to be removed.Type of change
Checklist
Additional for
Feature
type of change