Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharplet/sigswift
A toy, event-driven command line app inspired by the Elm Architecture
https://github.com/sharplet/sigswift
Last synced: 4 months ago
JSON representation
A toy, event-driven command line app inspired by the Elm Architecture
- Host: GitHub
- URL: https://github.com/sharplet/sigswift
- Owner: sharplet
- Created: 2017-12-08T18:59:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-08T21:05:57.000Z (about 7 years ago)
- Last Synced: 2024-10-04T10:27:19.491Z (5 months ago)
- Language: Swift
- Homepage:
- Size: 19.5 KB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sigswift
This was actually an excuse to design a completely event-driven terminal program in Swift.
It's inspired by the [Elm Architecture][].[](https://asciinema.org/a/151764?t=13)
How it works:
- Sets the terminal to [raw mode][], to enable processing input
character-by-character instead of line-by-line.- Configures a Grand Central Dispatch (GCD) `DispatchReadSource` to read from
standard input one character at a time.- Configures a number of GCD `DispatchSignalSource`s to process signals as
events.- With the event handlers in place, models the application as an `App` struct
that receives an `Event`, optionally updates its state, and dispatches an
array of `Action`.- No side effects are implemented in `App`, but are instead implemented in
top-level functions `handle()` and `dispatch()`, which convert `Action`s
into side effects.[Elm Architecture]: https://talk.objc.io/episodes/S01E66-the-elm-architecture-part-1
[raw mode]: https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode.html