Created
March 31, 2015 10:06
-
-
Save jsdf/7b71a590caaa6dccbd31 to your computer and use it in GitHub Desktop.
Use Faye pubsub with React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make sure you npm install 'url' (the browserify port of the node api url module) | |
var url = require('url') | |
var Faye = require('faye/browser/faye-browser') | |
var API_URL = 'http://localhost:8000/faye' | |
// initialise fake window.location - same origin as api host | |
// required to use some faye transports which expect to deal with same-origin policy. | |
// url.parse return value looks kind of like window.location, if you squint just right | |
window.location = url.parse(API_URL) | |
var client = new Faye.Client(API_URL) | |
client.publish('/blah', {}) // works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Almost a year old, but what's the benefit of doing it like this? and what about using
const Faye = require('faye')
and not the browser?