An app with The elm architecture demonstration made with ClojureDart on Flutter

0 0

clojure_dart_tea_example

ClojureDart Flutter project with demonstration of:

  • Graphql usage;
  • managing business logic and state with TEA*-like MVU architecture.
  • widget and nest macro from ClojureDart/alpha.

* The Elm architecture

Warnings!

This approach is not ready for production, just the idea demo.

MVU TEA-like architecture

I will provide my vision to the TEA.

There are 4 parts:

  1. Model – application state.
  2. Effects – side effect functions.
  3. Message – events that happens, like user click or effect result
  4. Update – function that takes old model and message, and return new model with list of effects.

To allow all this to work we have a dispatch function, that takes messages from all the source.

So in this app this components are:

  1. Model. State of the flutter/widget.
  2. Effects. Functions with the signature like (defn some-effect [dispatch-fn] ...)
  3. Messages. Keywords.
  4. Update. Function with the signature like (defn update [state message-key data]). Data is a part of the message abstraction.

For all this to work you don’t need a framework, just 1 dispatch function:

(defn- ^:async dispatch! [tea-update state-atom message data]
  (let [[new-state effects] (tea-update @state-atom message data)
        dispatch-for-effet-fn (partial dispatch! state-atom)]
    (reset! state-atom new-state) ;; state modification
    (doseq [e effects] (await (e dispatch-for-effet-fn)))))

Resources

GitHub

View Github

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Deja una respuesta

Entrada anterior A wallet application written in Flutter & Dart
Entrada siguiente A simple word guessing game developed using flutter/dart where you can choose the genre and the level of the game