horizon
horizon copied to clipboard
React Native Chat Example
Awesome! Thanks for submitting this PR
Hey @nivoc would you mind adding me as a collaborator on your fork so I can check out your branch?
cc: @mglukhovsky ^
@dalanmiller Sure. Added.
It sometime fails to connect (about 1 out of 10 times). Not sure yet why. Looks like some timing issue. Refresh helps (cmd+r in the simulator).
This is awesome @nivoc thank you. @mbseid could you show us how you got around auth/token/AsyncStorage?
Note: I've never done anything with react-native
so the tool chain is new to me.
To get the example to run properly I had to run the npm start
commands separately and there was maybe a race condition with the cli.js not being ready first I think. Not doing this gave me this error:
=== BUILD TARGET ReactNativeChatAppTests OF PROJECT ReactNativeChatApp WITH CONFIGURATION Debug ===
Check dependencies
** BUILD SUCCEEDED **
Installing build/Build/Products/Debug-iphonesimulator/ReactNativeChatApp.app
Launching org.reactjs.native.example.ReactNativeChatApp
org.reactjs.native.example.ReactNativeChatApp: 8227
events.js:154
throw er; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._writeGeneric (net.js:662:19)
at Socket._write (net.js:714:8)
at doWrite (_stream_writable.js:300:12)
at writeOrBuffer (_stream_writable.js:286:5)
at Socket.Writable.write (_stream_writable.js:214:11)
at Socket.write (net.js:640:40)
at Console.log (console.js:39:16)
at process.<anonymous> (server.js:124:15)
at emitOne (events.js:90:13)
at process.emit (events.js:182:7)
Then once I had it going I could save and write to the database but it looks like the changefeed isn't working properly:
The console output above shows I'm typing things into it and they're being stored but nothing is returning to the view?
I might've missed something just let me know what I need to fix here @nivoc. This thing was surprisingly easy to get setup and build, react-native
is really quite cool thank you for PRing this.
@dalanmiller oh good to know. Yes it sound's like a 'not ready'. Works for me - but I may have been lucky with the timing on my machine :-)
About the Changefeed
issue:
Try to press Command+r on the "no messages yet" screen.
There is an issue. I was not able to track it down yet. For me it works in 9 out of 10 connects but it's may be worse on your system. Press Command+R several times. But yes - needs to be fixed ;-)
Another thing is that the config.toml shouldn't be committed, since it has a token secret in it. I think it's good to have a convention that config.toml files never make it into the repo proper, to avoid confusion
removed.
About the Changefeed-Issue. It's odd. The "watch"-subscription gets called on every start. And it's always possible to write. But sometimes does the horizon not return the values.
I wonder if this is some artifact of WebSockets acting weird natively? Have you had other projects that use WebSockets without issues @nivoc or is this unique to Horizon?
@dalanmiller I haven't used WebSockets in RN enough to tell. But at least there are no open Issues in RN that sound like it: https://github.com/facebook/react-native/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+websocket