Skip to content

Sandbox branch for "lasagna" prototype#1669

Closed
raphlinus wants to merge 14 commits intomasterfrom
lasagna
Closed

Sandbox branch for "lasagna" prototype#1669
raphlinus wants to merge 14 commits intomasterfrom
lasagna

Conversation

@raphlinus
Copy link
Contributor

This is just a branch I'm using for experimenting with a layered architecture, code named "lasagna." At the moment it doesn't do anything, but has some basic types in place for tree mutation, app logic, etc. The goal is simply for me to learn whether the architectural ideas are viable.

raphlinus and others added 13 commits February 24, 2021 16:30
This is just experimentation and should not be taken seriously.
The Column even has an implementation of mutation. Not wired up to
window root (and no app logic, no actions).
The app logic is a function from actions to a mutation.

WIP checkpoint - this adds some of the types but does not yet build the
element tree from the app logic or deliver events.
Actually wire up mutations and an event flow so counting clicks works,
though of course it's still super rough in a variety of ways.
Create a vdom abstraction and use it to run the app logic.

The current implementation is an enum and the reconciler is very manual;
we'll want to replace that with a trait and a more systematic approach.
This is the start of an Elm-like pattern for building apps. There's now
a trait for the vdom (which is the correct direction; an enum is not
powerful enough), and support in the api for map functionality.
The "rusty" app architecture continues the exploration started with elm
but with important differences. The view tree is responsible for
dispatching events, rather than that being done in a big hash map
(maintained in the reconciliation process). Unlike elm, event callbacks
get mutable access to the app state.

Also moving in the direction of static types rather than downcasting,
but this is being done in stages.

WIP
The `Column` still uses erased types, but the underlying View type now
has an associated type for its state, and also takes the previous view.
We can use the view in MemoizeState, which is simpler and more efficient
than running the callback to generate a new view.
This implements the `View` trait for boxed views; possibly we want to
newtype this, as it requires a bunch of explicit derefs.

Also fixes a bug in memoize where it wasn't updating the view in the
memoize state.
Add ChildMutation datatype which optimizes as it's built, and avoids
allocation in the skip case.

Change the signature of the reconcile method to return a
MutationFragment rather than push an element onto a vec. This is a
cleaner return type and also optimizes the skip case.
There might be a more elegant way to do this, but for now putting the event body into Rc<RefCell> makes it work.
The "thunk" is now a concrete type rather than dyn Fn, which has a bunch of advantages: it can infer types better, and it doesn't need the interior mutability.
@raphlinus
Copy link
Contributor Author

I am closing this pull request as I do not anticipate further development of this branch. Going forward I anticipate more exploration in the idiopath branch, also called "Xilem."

@raphlinus raphlinus closed this May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant