@webqit/webflo 0.20.4-next.1 → 0.20.4-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ const config = {
|
|
|
46
46
|
{ text: 'Rendering', link: '/docs/concepts/rendering' },
|
|
47
47
|
{ text: 'Templates', link: '/docs/concepts/templates' },
|
|
48
48
|
{ text: 'State Management', link: '/docs/concepts/state' },
|
|
49
|
-
{ text: '
|
|
49
|
+
{ text: 'Requests & Responses', link: '/docs/concepts/requests-responses' },
|
|
50
50
|
{ text: 'Webflo Realtime', link: '/docs/concepts/realtime' },
|
|
51
51
|
]
|
|
52
52
|
},
|
|
@@ -339,7 +339,9 @@ Webflo knows to switch the connection to background mode in all the above cases.
|
|
|
339
339
|
- **Webflo simply fulfills the intent of however a handler works**.
|
|
340
340
|
:::
|
|
341
341
|
|
|
342
|
-
## Real-
|
|
342
|
+
## Real-World Examples
|
|
343
|
+
|
|
344
|
+
Below are some examples of how Webflo's realtime features work in action.
|
|
343
345
|
|
|
344
346
|
### Live Responses
|
|
345
347
|
|
|
@@ -371,7 +373,7 @@ This handler returns a skeleton object immediately for fast page load and then b
|
|
|
371
373
|
**_Result_:** The UI renders a skeleton first, then progressively fills in as the object tree is built from the server.
|
|
372
374
|
|
|
373
375
|
```js
|
|
374
|
-
import
|
|
376
|
+
import Observer from '@webqit/observer';
|
|
375
377
|
```
|
|
376
378
|
|
|
377
379
|
```js
|
|
@@ -597,24 +599,25 @@ export default async function (event, next) {
|
|
|
597
599
|
:::
|
|
598
600
|
|
|
599
601
|
::: warning
|
|
600
|
-
|
|
601
602
|
- Channel IDs must be unique and unguessable across the app.
|
|
602
603
|
- Channels are not persistent and are only active for the duration of the request. A database is required to store channel data.
|
|
603
|
-
|
|
604
|
+
:::
|
|
604
605
|
|
|
605
606
|
## Appendix A – The Realtime Lifecycle
|
|
606
607
|
|
|
608
|
+
The realtime lifecycle — from handshake to termination — can be summarized as follows. Note that this is the model between any two ports — Port A and Port B, not just between the client and the server, as that's only typical.
|
|
609
|
+
|
|
607
610
|
```mermaid
|
|
608
611
|
sequenceDiagram
|
|
609
|
-
participant
|
|
610
|
-
participant
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
Note over
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
612
|
+
participant Port A
|
|
613
|
+
participant Port B
|
|
614
|
+
Port A->>Port B: HTTP request
|
|
615
|
+
Port B-->>Port A: Initial Response (or a Temporary 202 Accepted) <br>+ X-Background-Messaging-Port
|
|
616
|
+
Port A-->>Port B: Connect (WebSocket / Broadcast / MessageChannel)
|
|
617
|
+
Note over Port A,Port B: Background mode established
|
|
618
|
+
Port B-->>Port A: Messages, updates, dialogs, etc.
|
|
619
|
+
Port A-->>Port B: Replies, requests, etc.
|
|
620
|
+
Port A<<-->>Port B: Termination
|
|
618
621
|
```
|
|
619
622
|
|
|
620
623
|
### The Handshake
|
|
@@ -622,7 +625,7 @@ sequenceDiagram
|
|
|
622
625
|
On entering background mode, Webflo initiates a handshake sequence as follows:
|
|
623
626
|
|
|
624
627
|
1. Webflo gives the initial response a unique `X-Background-Messaging-Port` header that tells the client to connect in the background after rendering the initial response.
|
|
625
|
-
> If the scenario is
|
|
628
|
+
> If the scenario is that the handler tiggers `event.client` messaging _before_ yielding a response, Webflo sends a temporary `202 Accepted` response to the client carrying this header.
|
|
626
629
|
2. The client reads that header and opens the background channel.
|
|
627
630
|
> If the client fails to connect within the handshake window, Webflo abandons the wait and concludes the request normally.
|
|
628
631
|
3. On connecting, both sides resume the same request context — now in live mode.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# State
|
|
1
|
+
# State, Mutation, & Reactivity
|
|
2
2
|
|
|
3
3
|
Webflo’s approach to state is refreshingly simple: your UI state is just a plain JavaScript object. When your server handler returns data, it becomes available as `document.bindings.data` for your templates and UI. No special syntax, no framework-specific magic—just JavaScript you already know.
|
|
4
4
|
|