This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-26
Channels
- # aleph (2)
- # beginners (119)
- # boot (18)
- # cider (19)
- # cljs-dev (46)
- # cljsjs (1)
- # cljsrn (30)
- # clojure (101)
- # clojure-dusseldorf (12)
- # clojure-finland (1)
- # clojure-greece (7)
- # clojure-india (2)
- # clojure-italy (6)
- # clojure-poland (4)
- # clojure-russia (120)
- # clojure-sg (3)
- # clojure-spec (147)
- # clojure-uk (75)
- # clojurescript (86)
- # cursive (4)
- # datomic (50)
- # docker (1)
- # emacs (4)
- # juxt (51)
- # leiningen (16)
- # liberator (1)
- # luminus (1)
- # lumo (116)
- # mount (2)
- # off-topic (2)
- # onyx (38)
- # pedestal (4)
- # protorepl (2)
- # re-frame (44)
- # reagent (8)
- # ring-swagger (16)
- # schema (5)
- # specter (16)
- # test-check (226)
@mengu, not android drawer, but have used DrawerNavigator from http://reactnavigation.org
I'm trying to get react-native-signalone
to work with cljsrn. It shouldn't be that hard:
import OneSignal from 'react-native-onesignal'
export default class App extends Component {
componentWillMount() {
OneSignal.addEventListener('received', this.onReceived);
...
}
onReceived(notification) {
...
}
Translating to cljsrn (rum/re-natel):
(def OneSignal (js/require "react-native-onesignal"))
(defn ^:export onreceived [notification]
...)
(def one-signal-mixin
{:will-mount (fn [state]
(doto OneSignal
(.addEventListener "received" onreceived))
...
})
(defc AppRoot < rum/reactive one-signal-mixin
[state]
...
)
However, I'm getting this error:
can't find what I'm doing wrong...
$ cat index.android.js
var modules={'react-native': require('react-native'), 'react': require('react')}; ... ;modules['react-native-onesignal']=require('react-native-onesignal');
require('figwheel-bridge').withModules(modules).start('...');
ok, makes sense... so... why, or how to make it imported? I thought this line (def OneSignal (js/require "react-native-onesignal"))
would do?
https://github.com/geektimecoil/react-native-onesignal/blob/master/index.js#L29
export default class OneSignal {
or just enable chrome dev tools debugging and (js/console.log OneSignal)
right after import
(def OneSignal (.-default (js/require "react-native-onesignal")))
does seem to help - no error so far. What's the reason?
well... that .-default
did the trick. Oh, export default class OneSignal
- I'm not very familiar with ES6 (it is ES6, right? :p)
so, OneSignal
is available as export
(at least in cljs... in js, one seem to be able to use OneSignal - oh, I think I get it: static methods?)
if something is exported as default
- you need to explicitly "navigate" to it.
basically require gives you "js ns object". An actual class you need will either be in ns.default
or in ns.ActualClass
(and maybe it will be ns
in case of es5?).
so you have 3 things to try:
(def MyClass (js/require "some-lib"))
;; or
(def MyClass (.-default (js/require "some-lib")))
;; or
(def MyClass (.-MyClass (js/require "some-lib")))
right. thx.
Hi all! where I can find some examples about react native navigator with clojurescript? thanks!
@manu Do you mean https://reactnavigation.org? If so https://github.com/vikeri/re-navigate or https://github.com/amorokh/om-navigate might be interesting
@manu You probably don’t want to use that, it’s very object oriented and I don’t think it’s very maintained
and have performance problems)
I'm studying a code made by another and in the future I'll improve it. but for now I'm just trying to understand the code ^^'
and because of there is navigator, but it is used in a very hard way, I would like to see some easier examples 🙂