Add some examples to README or Wiki
Closed this issue · 7 comments
Hi.
I've been experimenting natal for the last three days and I must say it's a great project. Today I started developing my first serious app with it.
I have some experience developing with Clojure and Java but now I need to learn React Native and ClojureScript for a project we started a couple weeks ago.
Is there a sample app using natal? Or any examples to help me learning how to "compose my components" properly?
Thanks in advance,
Felipe
For example: I'm trying to write this snippet from RN's docs in cljs but it throws an error.
JSX
AlertIOS.alert(
'Foo Title',
'My Alert Msg',
[
{text: 'Foo', onPress: () => console.log('Foo Pressed!')},
{text: 'Bar', onPress: () => console.log('Bar Pressed!')},
]
)
ClojureScript (om-next)
(alert
"Foo Title"
"My Alert Msg"
[{:text "Foo" :onPress #()}
{:text "Bar" :onPress #()}])
TypeError: buttons.forEach is not a function. (In 'buttons.forEach', 'buttons.forEach' is undefined)
Natal is fairly new so there aren't a lot of example apps I know of yet, but here are two that should help:
https://github.com/iamjarvo/zooborns
https://github.com/dvcrn/om-react-native-demo
As for the issue you're seeing, I think you need to wrap the array argument in clj->js
which will recursively convert the ClojureScript vector and maps into native Javascript objects.
Right now the Natal Shell interop macros are very naive and simply dump the arguments as given.
In the future we could try to make it more aware of argument types so it could auto convert them.
You can also try writing your example using tagged literals like:
(alert
"Foo Title"
"My Alert Msg"
#js [#js {:text "Foo" :onPress #()}
#js {:text "Bar" :onPress #()}])
Or at runtime with clj->js
:
(alert
"Foo Title"
"My Alert Msg"
(clj->js
[{:text "Foo" :onPress #()}
{:text "Bar" :onPress #()}]))
Great! Thank you for the quick reply, @dmotz :)
@dmotz @felipebueno here's a quick markdown doc i made showing a getting started with emacs example, let me know if you want me to modify and drop in the wiki:
I added links to example apps to the readme. Feel free to add others you know of.
@chadhs Hoping to make the Cider compatibility more painless, but in the meantime feel free to add your guide to the wiki.