I'm trying to use ratchet for reflecting the changes made to my database realtime. I used the code of the pusher app (http://socketo.me/docs/push). But i am getting error in that.
The moment I open the client side page :
Uncaught ReferenceError: module is not defined when.js:900
(anonymous function) when.js:900
(anonymous function) when.js:15
(anonymous function) when.js:900
After this I typed: conn.subscribe('topic'); //This subscribes the topic.
Now the moment I make changes to this topic, an error pops up where the changes are to be displayed.
Error 2 :
Uncaught TypeError: undefined is not a function [VM] autobahn.min.js (124):66
(anonymous function) [VM] autobahn.min.js (124):66
c._websocket.onmessage [VM] autobahn.min.js (124):66
Any help ?
This may be solvable by using the following JavaScript before including the when.js
file:
window.define = function(factory) {
try{ delete window.define; } catch(e){ window.define = void 0; } // IE
window.when = factory();
};
window.define.amd = {};
Then, include your when.js
file.
This is because you're using the when.js without using a module system such as AMD.
The docs explain how to transform the file to work in a browser through use of browserify, so long as you've done n
Since when.js primarily targets modular environments, it doesn't export to the global object (window
in browsers) by default. You can create your own build of when.js using browserify, if you prefer not to use an AMD or CommonJS loader in your project.
git clone https://github.com/cujojs/when
npm install
npm run browserify
to generate build/when.js
npm run browserify-debug
to build with when/monitor/console enabled<script src="path/to/when/build/when.js"></script>
when
will be available as window.when
window.when.fn.lift
, window.when.sequence
. See the full sub-namespace list in the browserify build fileIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With