Giter VIP home page Giter VIP logo

phoenix-react-native-mashup's Introduction

What is this Foul Sorcery?

Here's an example of using React Native to talk to a Phoenix server with WebSockets.

Screenshot

The Blog Post

For more background and some more in-depth commentary, check out my blog post that goes with this repo.

https://medium.com/@skellock/prototyping-a-chat-app-with-react-native-and-phoenix-5e65677a8217

About The Client

Since this is just a sample, I'm going to pretend errors and timeouts don't exist.

In the code:

  • Phoenix.js - the official JS client that ships with Phoenix framework.
  • Chat.js - a silly wrapper around the Phoenix sockets and channel interfaces.
  • Root.jsx - the user interface

The UI revolves around a hilariously fantastic 3rd party component called Gifted Messenger:

https://github.com/FaridSafi/react-native-gifted-messenger

About The Server

The server is Chris McCord's example. The only change I made was to turn off the server-generated PING message every 5 seconds.

https://github.com/chrismccord/phoenix_chat_example

I just included it here for convenience. I ghetto-forked it as of 02bbbc8a295542146aef4e347dcbdc5fd0aadd69 on Feb 13, 2016. He does a great job of keeping it up to date, and you should use his for your own adventures.

Running The Server

Make sure you've installed Elixir 1.2.2+.

  • cd ChatServer
  • mix deps get
  • npm install (recommended: for a web version of the client)
  • grab a coffee
  • mix phoenix.server

After a quick 1-time compile, your server is now up & running. If you installed the web client then browser to http://localhost:4000

Running The Client

Make sure you have React Native 0.19+ installed on your ride.

  • cd ChatClient
  • npm install
  • grab a coffee
  • react-native run-ios or react-native run-android

If you're running android, you might need to reverse map some ports to get to the chat server by running

  • $ANDROID_HOME/platform-tools/adb reverse tcp:4000 tcp:4000

\o/

phoenix-react-native-mashup's People

Contributors

skellock avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.