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 debouncing example #256

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ lazy val counter =
.settings(commonSettings: _*)
.settings(name := "counter")

lazy val debouncing =
(project in file("debouncing"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(name := "debouncing")

lazy val electron =
(project in file("electron"))
.enablePlugins(ScalaJSPlugin)
Expand Down Expand Up @@ -177,6 +183,7 @@ lazy val exampleProjects: List[String] =
"bundler",
"clock",
"counter",
"debouncing",
"electron",
"field",
"fs2",
Expand Down
21 changes: 21 additions & 0 deletions examples/debouncing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tyrian debouncing example

Input debouncing is a technique used to ensure that a function or action is triggered only after a certain period of inactivity of an input, typically to prevent multiple rapid calls or events from occurring in a short timeframe. This is commonly used in scenarios where user input, such as button clicks or keyboard events, can lead to actions like API calls.

This is an example of how to implement input debouncing with Tyrian according to [a recipe from Elm](https://orasund.gitbook.io/elm-cookbook/recipes-1/writing-a-single-page-application/debounced-validation).

To run the program in a browser you will need to have yarn (or npm) installed.

On first run:

```sh
yarn install
```

and from then on

```sh
yarn start
```

Then navigate to [http://localhost:1234/](http://localhost:1234/).
14 changes: 14 additions & 0 deletions examples/debouncing/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>Tyrian Debouncing Example</title>
</head>

<body>
<div id="myapp"></div>
<script type="module" src="./tyrianapp.js"></script>
</body>

</html>
Loading
Loading