https://github.com/refi64/grex
https://github.com/refi64/grex
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/refi64/grex
- Owner: refi64
- License: mpl-2.0
- Created: 2021-08-05T01:02:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T02:05:53.000Z (about 4 years ago)
- Last Synced: 2025-03-16T01:41:25.413Z (over 1 year ago)
- Language: C
- Size: 433 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Grex
Grex is a very rough project aiming at bringing reactive development to GTK,
complete with nice extras such as hot reload. The approach is heavily inspired
by [the "incremental DOM" approach used by
Angular](https://google.github.io/incremental-dom/).
Please see the [introductory blog
post](https://refi64.com/posts/introducing-grex.html) for more information.
TODO: actual documentation here
## Concepts
Consider the following XML file:
```xml
```
The entire XML document is referred to as a *template*, and the individual
elements are *fragments*. These fragments are converted to a GTK widget tree
during a process known as *inflation*, with each inflated widget holding a
*fragment host* that manages the widget's state.
Each attribute & value in a fragment are its *bindings*. The values can take
three forms:
- `attr="[expression]"` - one-way binding, will set the property `attr` on the
fragment's widget with the result of `expression`, re-applying the value when
an inflation occurs
- `attr="{expression}"` - two-way binding, similar to one-way bindings, but, if
the widget's `attr` changes, it will be assigned to `expression`
- `attr="some text [expression] some text"` - compound binding, similar to
one-way bindings, but allows you to place text between and around the
bindings, with the binding's result now being a string
### Directives
A core part of Grex are *directives*. Any binding whose attribute starts with a
capital letter is a directive, and, instead of setting the value directly on the
target, the value will be passed to the directive, which can then manipulate the
fragment host as desired.
Directives can also be *structural*, indicated by a leading `_`. These
directives will be given the fragment and are responsible for inserting the
fragment into its parent.