Forge frontend tech update
Introduced lately
- Haxe
- tink_core
- Typed reflibs
- tink_state
Haxe
- DevTalks Winter 2020
- Code Style Guide
tink_core
Generic type-safe building blocks for common problems
- CallbackLink
- Future
- Outcome
- Promise
- Signal
- some other stuff
tink_core: CallbackLink
- For all kinds of "cancellable" registrations/operations
- Most often used for callbacks (thus the name)
- Public API: the cancel() method ;-)
- Ensures single invokation
- Create from a function
- Join multiple into a single CallbackLink
- null is a valid value (noop, not NPE)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8032922/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305471/pasted-from-clipboard.png)
tink_core: Future
- Represents asynchronous result
- Composability
- inParallel/inSequence
- map/flatMap
- FutureTools.combine
- Can be lazy and suspendable
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8037059/pasted-from-clipboard.png)
tink_core: Future
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305505/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305509/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305515/pasted-from-clipboard.png)
tink_core: Future
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305610/pasted-from-clipboard.png)
tink_core: Outcome
- Represents success/failure outcome
- Explicit and type-safe
- Helper methods included
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8046912/pasted-from-clipboard.png)
tink_core: Promise
- Represents asynchronous outcome
- Essentially a Future<Outcome<T,Error>>
- Same API as Future
- + convenience methods for dealing with errors
- next
- recover
- Promise.resolve
- Promise.reject
- etc.
- Our own helpers:
- then
- PromiseTools.combine
tink_core: Promise
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305677/pasted-from-clipboard.png)
tink_core: Promise
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305711/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305717/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305718/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8305719/pasted-from-clipboard.png)
tink_core: Signal
- Generic one-to-many notification primitive
- Listener API separate from trigger API
- Composability
- map/filter
- nextTime
- Can be lazy and suspendable
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8046966/pasted-from-clipboard.png)
Typed reflibs
- Type-safe asset libraries
- Generated by ATC
- defined via gunnerfile
- in sync with asset repo
- More info here
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8046993/pasted-from-clipboard.png)
OnStageHandler
- Do actions when object comes to the stage
- Undo actions when it leaves the stage
- GC-friendly, replaces explicit dispose in most cases
- Great for managing external bindings
- Event/Signal
- Observable
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8047031/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8047068/pasted-from-clipboard.png)
tink_state: Reactive State Handling
- Observable state primitives
- Automatic derived data updates
- Efficient computations and bindings
- Plays well with tink_core
- ObservableArray/ObservableMap
tink_state: The Idea
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8053874/pasted-from-clipboard.png)
tink_state: The Idea
Inventory state
(from BE)
Search string
(from User)
Current page
(from User)
Matching items
Items to display
Number of pages
Has prev page?
Has next page?
tink_state: Basics
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8047106/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8047108/pasted-from-clipboard.png)
tink_state: binding
- Synchronously calls handler for the first time
- On-change binding invokations are batched
- bindings are invoked once per frame
- bindings are only invoked if the value actually changes
- Configurable
- custom comparators
- direct invokation instead of batching
tink_state: auto-observable
- Create observables from a compute function
- Automatically tracks "parent" observables
- Invalidates when parents change
- Recomputes on the next access
- and caches the result until next invalidation
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8092513/pasted-from-clipboard.png)
tink_state: Predicted/Promised
![](https://s3.amazonaws.com/media-p.slid.es/uploads/80378/images/8092533/pasted-from-clipboard.png)
Convenience tools for observing Future/Promise results
Forge frontend tech update
By Dan Korostelev
Forge frontend tech update
- 1,085