# MatrixRN -- The Petri Dish
Two scrolls down you will find [the read-me](https://github.com/kennytilton/matrix/blob/master/cljs/expo/matrixrn/README.md#react-native-using-shadow-cljs-in-3-minutes) from the original [rn-rf-shadow](https://github.com/PEZ/rn-rf-shadow) project from which this effort was cloned. That will help you set up different IDE stacks.
What follows are rough directions to help the early curious explore MatrixRN. But first a caveat.
> Caveat adaptor: I am comfortable with Matrix reactive logic and UIs in general, having wrapped a dozen libraries like ReactNative, but I am no rock star when it comes to React Native or CLJS build tools such as Figwheel, shadow-cljs, and Krell. Advice on RN or builds will be welcome!
## Did I say "Petri dish"?
![A Petri dish](../../../images/mx-banner-red.jpg)
I call this the Petri dish because it is where I am cultivating MatrixRN. It feels done, but it will grow as we implement new RN sample projects. That may seem obvious, but in the case of React Native I am finding that every widget brings surprises; it lacks the consistency of HTML's `<tag attributes*>children</tag>`. MatrixRN will paper these over where possible, and grow with each papering.
The good news is that, so far, we have needed just 150LOC to wrap ReactNative with Matrix, a mature, truly reactive state manager that harkens back twenty-five years to its Common Lisp progenitor. We have done this by letting RN be RN, doing no more than using React state hooks to connect Matrix state change management with React rendering and events.
Furthermore, MatrixRN wraps ReactNative thinly. We use props with functional components, and have access to `createElement` as the examples show. If we know RN, we can code with MatrixRN.
## Psst! re-frame?
`re-frame` is a sophisticated and proven UI/UX framework. So why MatrixRN?
We will cover more in a Wiki write-up, but Matrix is quite simply an inside-out different approach to GUIs. Where `re-frame` works by analytic desconstruction, Matrix works organically. `re-frame` has us break down an application problem into so many events, subscriptions, and views. Matrix accepts the problem in its natural form.
These different approaches will suit different developers. `re-frame` fits those who enjoy seeing the structure of a problem laid out as so many `re-frame` artifacts, neatly organized by type of artifact into different directories. Matrix suits those who want to code applications organically, in the image of the problems they solve. Events, dependencies, state change, and views are all co-located and largely transparent.
More soon in a Wiki walk-through of these POC examples.
## Running the demo project
In a terminal:
* clone the entire [Matrix repo](https://github.com/kennytilton/matrix);
* `cd (matrix location)/cljs/expo/matrixrn`;
* `npm install`
* `npx shadow-cljs watch app` to start compilation;
* * Note! While working on the code, watch this terminal for compilation errors;
* wait for `[:app] Build completed....` before continuing to the next step.
In a new terminal:
* `npm start`;
After quite a bit of work and more than a few scary errors...
* an iOS sim will appear; wait quite a while for it to complete loading;
* you should be looking at what I call the "Sampler";
* * here I load the most complete solutions to each lesson;
* Using the Simulator menu bar, select `Device>shake`;
* * a menu of options should appear in the sim;
* if you see an option to `Disable fast refresh` select it; the menu will disappear;
* * (If it says "enable", do nothing, we are good.)
* again, select `Device>shake`;
* if you see an option to `Debug`, select it; a debug web page will appear: "localhost:8081/debugger-ui/"
* * once you get the debugger-ui web page to appear, enter the developer console to see application prints and exceptions.
To get started on the tutorial lessons, in your chosen IDE:
* open the `(matrix location)/cljs/expo/matrixrn` directory/project; (<-- this path is a change!)
* open `(matrix location)/cljs/expo/matrixrn/app.cljs`
* * change `[matrixrn.demo.tutorial.sampler :as demo]` to `[matrixrn.demo.tutorial.main :as demo]`
* open `matrixrn/demo/tutorial/main.cljs`;
* make sure `(hello/lesson)` is the only uncommented item under the `Navigator`;
* * if not, comment/uncomment as needed.
Now read the source and learn how that example works, and which Matrix tricks are demonstrated.
Where a lesson suggests something like `TryThis[times-six,easy]`, look for a solution named `times-six` in the same directory as the lesson.cljs. The temptation will be great, but we recommend trying to solve the challenges before looking at the solutions. Your call.
If you have questions/problems, please reach out. This doc needs your input. Here are two options:
* raise an issue on this repo (slower);
* ping @kennytilton in the #matrix or #cljsrn channels of clojurians.slack.com (faster).
Finally: pull often; the petri dish is growing all the time.
## Editing the demo project. I use Cursive
I use Cursive, and had to deal with the lack of a deps.edn. It is my fault. They took it out when I got confused, not knowing Cursive relied on it.
That is OK. Follow these steps for a solid Cursive experience:
* from IntelliJ, select `File>New>Project from existing sources...`;
* navigate to `_repoLocation_/cljs/expo/matrixrn` and open the `pom.xml`; and
* yer done.
We now return you to the original read-me.
# React Native using shadow-cljs in 3 minutes
The fastest way a [ClojureScript](https://clojurescript.org/) coder can get started with React Native development. *Prove me wrong.*
This is an example project, only slightly beyond *Hello World*, using: [shadow-cljs](https://github.com/thheller/shadow-cljs), [React Native](https://facebook.github.io/react-native/), [Expo](https://expo.io/), [Reagent](https://reagent-project.github.io/), and [re-frame](https://github.com/Day8/re-frame).
<div style="display: flex; justify-content: space-around;">
<div style="flex: 1"><img src="./rn-rf-shadow.png" width="240" /></div>
<div style="flex: 1">Check this video out for a demo of this project.<br>
<a href="https://www.youtube.com/watch?v=QsUj7HO5xDg"><img src="https://img.youtube.com/vi/QsUj7HO5xDg/maxresdefault.jpg" width="320px"><br>
ClojureScript ❤️ React Native</a>
</div>
</div>
Follow along to get started. There are instructions for [Calva](http://calva.io), [Emacs/CIDER](https://cider.mx), [Cursive](https://cursive-ide.com), and the command line. It is assumed you have Java and Node installad as well as dev tool chains for the platforms you are targeting. (If you are targeting the Web, then Chrome is enough.)
## Installing
To facilitate that you can easily try this out without installing anything globally on your machine, this project installs everything it needs locally in `node_modules`. Then `npx` is used to execute tools like `expo-cli`.
To install dependencies, and setup the project, run:
1. `npm i`
From there use your favorite editor and/or the prompt.
## Using VS Code + Calva
0. Install the [Calva](https://calva.io) extension in VS Code.
1. Open the project in VS Code. Then:
1. Run the Calva command **Start a Project REPL and Connect (aka Jack-in)**
1. Select the project type `Hello RN Shadow`.
1. Wait for shadow to build the project.
1. Then **Run Build Task**. This will start Expo and the Metro
builder. Wait for it to fire up Expo DevTools in your browser.
1. Click **Run in web browser**
1. When the app is running the Calva CLJS REPL can be used. Confirm this by evaluating something like:
``` clojure
(js/alert "Hello world!")
```
(You should see the alert pop up where the app is running.)
1. Hack away!
Of course you should try to fire up the app on all simulators, emulators and phones you have as well. The Expo UI makes this really easy.
## Using Emacs with CIDER
Open Emacs and a bash shell:
1. Run `npx shadow-cljs compile :app` to perform an initial bui
没有合适的资源?快使用搜索试试~ 我知道了~
生成对象之间的细粒度、透明数据流。_HTML_Dart_.zip
共692个文件
js:80个
png:77个
cljs:62个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 82 浏览量
2023-04-13
23:37:06
上传
评论
收藏 17.09MB ZIP 举报
温馨提示
生成对象之间的细粒度、透明数据流。_HTML_Dart_.zip
资源推荐
资源详情
资源评论
收起资源包目录
生成对象之间的细粒度、透明数据流。_HTML_Dart_.zip (692个子文件)
_BUCK 1KB
3941719221.basis 53KB
3941719221.basis 53KB
gradlew.bat 3KB
release.bat 66B
release.bat 66B
brepl.bat 64B
build.bat 64B
watch.bat 64B
brepl.bat 64B
build.bat 64B
watch.bat 64B
repl.bat 63B
repl.bat 63B
brepl 71B
brepl 71B
.buckconfig 114B
build 71B
build 71B
build_defs.bzl 602B
generated_plugin_registrant.cc 164B
generated_plugin_registrant.cc 164B
mxrgen.clj 7KB
core_test.clj 7KB
mxreact.clj 7KB
matrixrn.clj 5KB
project.clj 2KB
linked_list_test.clj 2KB
project.clj 1KB
project.clj 1KB
project.clj 1KB
spamgen.clj 721B
project.clj 568B
release.clj 304B
release.clj 302B
build.clj 294B
build.clj 291B
brepl.clj 259B
brepl.clj 255B
watch.clj 143B
watch.clj 129B
repl.clj 92B
repl.clj 92B
base_test.clj 30B
core_test.cljc 28KB
evaluate.cljc 26KB
core_test.cljc 17KB
core.cljc 16KB
core.cljc 14KB
core.cljc 14KB
evaluate_test.cljc 9KB
synapse_test.cljc 8KB
opti_freeze_test.cljc 8KB
base.cljc 8KB
hello_cells_test.cljc 7KB
api.cljc 7KB
integrity_test.cljc 7KB
mxpipe.cljc 7KB
integrity.cljc 6KB
core_test.cljc 6KB
pipeline.cljc 5KB
core.cljc 5KB
core_test.cljc 4KB
synapse.cljc 4KB
base.cljc 4KB
watch_test.cljc 4KB
opti_test.cljc 3KB
pipeline_test.cljc 3KB
lazy_cells_test.cljc 3KB
base.cljc 3KB
kids_test.cljc 3KB
mxpipe_test.cljc 3KB
poly.cljc 1KB
watch.cljc 1KB
diagnostic.cljc 1KB
async_test.cljc 979B
stopwatch.cljc 894B
evaluate.cljd 21KB
core.cljd 12KB
model_core.cljd 11KB
evaluate.cljd 9KB
core.cljd 8KB
synapse.cljd 7KB
integrity.cljd 7KB
hello_cells.cljd 7KB
cell_core.cljd 6KB
integrity.cljd 6KB
base.cljd 5KB
core.cljd 4KB
core.cljd 4KB
testing.cljd 4KB
synapse.cljd 3KB
mx_cljd_world.cljd 3KB
lazy_cells.cljd 3KB
base.cljd 3KB
observer.cljd 3KB
observer.cljd 2KB
family_kids.cljd 2KB
base.cljd 2KB
cljd_world.cljd 1KB
共 692 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功