Created
September 11, 2023 13:11
-
-
Save daveliepmann/b57d03c9c0eb7161962917d80f2db77a to your computer and use it in GitHub Desktop.
clojuredart mvp of loading edn from asset file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sample.load-edn | |
"Load EDN from asset on startup" | |
(:require | |
["package:flutter/material.dart" :as m] | |
["package:flutter/widgets.dart" :as f.widgets] | |
["package:flutter/services.dart" :as f.services] | |
[cljd.flutter :as f] | |
[cljd.reader])) | |
(def !state (atom {})) | |
(defn set-up! [] | |
(f.widgets/WidgetsFlutterBinding.ensureInitialized) | |
(swap! !state merge | |
(cljd.reader/read-string | |
(await (f.services/rootBundle.loadString "assets/foo.edn"))))) | |
(defn main [] | |
(set-up!) | |
(f/run | |
(m/MaterialApp) | |
.home | |
(m/Scaffold .appBar (m/AppBar)) | |
.body | |
(f/widget :watch [state !state] | |
(m/Text (str state))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment