You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-54Lines changed: 82 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ let demo =
14
14
```
15
15
16
16
[Falco.Datastar](https://github.com/SpiralOSS/Falco.Datastar) brings type-safe [Datastar](https://data-star.dev) support to [Falco](https://github.com/pimbrouwers/Falco).
17
-
It provides a complete mapping of all [plugin attributes](https://data-star.dev/reference/attribute_plugins) and [plugin actions](#https://data-star.dev/reference/action_plugins).
17
+
It provides a complete mapping of all [attribute plugins](https://data-star.dev/reference/attribute_plugins) and [action plugins](https://data-star.dev/reference/action_plugins).
18
18
As well as helpers for retrieving the signals and responding with Datastar Server Side Events.
19
19
20
20
## Key Features
@@ -127,7 +127,7 @@ Some important notes: Signals defined later in the DOM tree override those defin
127
127
-[Miscellaneous Actions](#miscellaneous-actions)
128
128
-[When to $](#when-to-)
129
129
130
-
###_Creating Signals_
130
+
## _Creating Signals_
131
131
132
132
Create signals, which are reactive variables that automatically propagate their value to all references of the signal.
133
133
@@ -151,7 +151,7 @@ As a convenience, you can create a single signal with the option to add it only
151
151
**Important note**: if you use kebab-case, it will be returned in pascal-case.
@@ -194,7 +194,7 @@ The previous example uses a couple functions we haven't covered yet. [`Ds.onClic
194
194
[`Ds.attr'`](#dsattr--data-attr) and [`Ds.show`](#dsshow--data-show) are evaluating the Datastar expression `$fetching` and are assigning `disabled` attribute and
195
195
show/hiding the div, respectively, based on the `fetching` signal value's "true-ness".
196
196
197
-
###_Signal Binding_
197
+
## _Signal Binding_
198
198
199
199
Binding to a signal means tying an attribute or value of an element to a value that can be modified by another effect.
200
200
Example: setting the innerText of a `<div>` to a value that is updated by a server; or, toggling an HTML `class` on an element.
Sets the [`view-transition-name`](https://developer.mozilla.org/en-US/docs/Web/CSS/view-transition-name) style attribute
249
-
explicitly.
248
+
Sets the [`view-transition-name`](https://developer.mozilla.org/en-US/docs/Web/CSS/view-transition-name) style attribute explicitly.
250
249
251
250
```fsharp
252
251
Elem.div [ Ds.viewTransition "$foo" ]
@@ -266,51 +265,39 @@ Elem.form [] [
266
265
]
267
266
```
268
267
269
-
###_Events and Triggers_
268
+
## _Events and Triggers_
270
269
271
270
Events and triggers result in [Datastar expressions](https://data-star.dev/guide/datastar_expressions) being executed. This can possibly result in signal changes and other expressions being run.
272
271
Example: clicking a button to send a request or update the visibility on an element via [Ds.show](#dsshow--data-show).
Attaches an event listener to an element, executing an expression whenever the event is triggered.
275
+
Attaches an event listener to an element, executing a [Datastar expression](https://data-star.dev/guide/datastar_expressions) whenever the event is triggered.
276
+
An `evt` variable that represents the event object is available in the expression.
| Interval // Triggered every 1 second; can be modified with Duration.With(TimeSpan.FromSeconds _)
288
-
| RequestAnimationFrame // Triggered on every requestAnimationFrame event. https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame
289
-
| SignalsChanged // Triggered when any signal changes
290
-
| SignalChanged of signalPath:SignalPath // Triggered when a specific signal changes
291
-
| Other of string // A custom event; https://developer.mozilla.org/en-US/docs/Web/Events
292
-
```
293
-
294
-
There are helper methods for `Ds.onEvent(Click, ...)` and `Ds.onEvent(Load, ...)`:
283
+
There are helper methods for `Ds.onEvent("click", ...)` and `Ds.onEvent("load", ...)`:
Modifiers allow you to alter the behavior when events are triggered. (Modifiers with a '*' can only be used with the [built-in events](https://data-star.dev/reference/attribute_plugins#special-events)).
292
+
Modifiers allow you to alter the behavior when events are triggered. (Modifiers with a '*' can only be used with the [built-in events](https://developer.mozilla.org/en-US/docs/Web/Events)).
304
293
305
294
```fsharp
306
295
type OnEventModifier =
307
296
| Once // * - can only be used with built-in events
308
297
| Passive // * - can only be used with built-in events
309
298
| Capture // * - can only be used with built-in events
310
-
| Delay of TimeSpan
311
299
| Debounce of Debounce // timespan, leading, and notrail
312
300
| Throttle of Throttle // timepan, noleading, and trail
313
-
| Duration of Duration // timespan and leading
314
301
| ViewTransition
315
302
| Window
316
303
| Outside
@@ -321,7 +308,7 @@ Modifiers allow you to alter the behavior when events are triggered. (Modifiers
0 commit comments