Reactive = Document +
Event +
Types
Me
@LBdN
My biases
- big/complex UI
- heavy client
- 3d
The problem
UI Complexity
App Complexity
Solution
Sources
- Deprecating the Observer Pattern - Ingo Maier Tiark Rompf Martin Odersky
- Erik Meijer : What is means to be reactive ?
- StackOverflow : What's FRP ?
Goals
- Easy UI change
- Undo/Redo built-in
- Save/Load built-in
Concepts
- Streams & stream composition
- Events : next, error, end
- Types
My version : reactive2
- Python descriptors as stream
- document as hierarchy of stream
- reversable events
- subsystems (IO, display, etc) communicate only via events and are peripheral
Python descriptors
myinstance.myattr=1 is translated by the interpreter as
myinstance.__class__.myattr.__set__(myinstance, 1)
myinstance.__class__.myattr is a descriptor. And it's über cool. Because we can intercept assignment.
Reactive Python Descriptor
- react to assignment and send events when it happen
- wrap a single attribute
(in reactive2, see base.py)
The Document
- A hierarchy of objects
- with attributes wrapped by reactive descriptors
- the complete data of the app.
(in reactive2 see examples/todo.py)
The events
- only atomic operations : replace, append, insert, remove.
- can be reversed
- can be applied to a reactive descriptor
(in reactive2 see event.py)
Subsystems
- read data from events, and translate them into domain
- may modify other part of the document.
Subsystem examples : History
- register to all wrapped attributes of the document. (tree descent)
- record N last events
- Undo/Redo is reversing the last event, and applying it
- (psss... Save/Load is saving on disk all the events)
Subsystem examples :
3D display
- Main document has an 3d object list
- Via another subsystem, a new 3d object is added to it.
- It triggers an event that the 3d display listens to.
- The 3d display translated it into openGL/DirectX calls
Take away
- Works
- Extremist (all or nothing, architectural)
- Need thinking
- Not finished
No silver bullet
But Extremely useful
Connect !
- @LBdN
- https://bitbucket.org/lbarret/reactive2
- http://fr.linkedin.com/in/lionelbarretdenazaris
Questions ?
reactive : document + events + types
By Lionel Barret
reactive : document + events + types
- 1,541