rx-flux
rx-flux copied to clipboard
Question(s) on using the library
Hello,
First of all, thanks for the lib! I've skimmed over the README and I was eager to try it and see if it helps me.
However, I've stumbled over (maybe because of my not-so-proficient JS dev) in trying to use it. More specifically, I'm trying out the Store class, in a new, simple node.js app. However, the "class" keyword and way of declaring MyStore is weird. Is that ES6? - would help a lot to have that written in the README.
I also tried to get the examples working but none work :( - e.g.: trying to restore the modules via npm install throws errors.
Anyway, here is a sample .js file that TypeScript generates, using rx-flux:
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var http = require('http');
var port = process.env.port || 1337;
var Store = require('rx-flux').Store;
var MyStore = (function (_super) {
__extends(MyStore, _super);
function MyStore(value) {
_super.call(this);
this.setValue(value);
}
return MyStore;
})(Store);
var myStore = new MyStore(['foo', 'bar']);
console.log(myStore.getValue()); // ['foo', 'bar']
myStore.subscribe(function (value) {
console.log(value); // ['foo', 'bar']
});
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port);
//# sourceMappingURL=server.js.map
It's a really simple example, which sadly doesn't work:
NodejsRxFlux\server.js:13
_super.call(this);
^
TypeError: undefined is not a function
at new MyStore (NodejsRxFlux\server.js:13:16)
at Object.<anonymous> (NodejsRxFlux\server.js:19:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Am I missing something? The README is not very helpful sadly :(
Thanks.