brownplt / flapjax Goto Github PK
View Code? Open in Web Editor NEWfunctional reactive programming for JavaScript
Home Page: http://www.flapjax-lang.org/
License: BSD 3-Clause "New" or "Revised" License
functional reactive programming for JavaScript
Home Page: http://www.flapjax-lang.org/
License: BSD 3-Clause "New" or "Revised" License
If the request somehow failed, (eg. error 404, 500, server offline) there's no way of knowing except by leaking the implementation. Perhaps give the EventStream return by getWebServiceObjectE a new property which contains an EventStream that propagates any errors that might have occured.
Another solution would be to always return the XHR object, whether the request failed or not. That way a developer can check for any errors.
The definition of EventStream.ifE reads as follows:
EventStream.prototype.ifE = function(thenE,elseE) {
var testStamp = -1;
var testValue = false;
createNode([this],function(pulse) { testStamp = pulse.stamp;
testValue = pulse.value; return doNotPropagate; });
return mergeE(createNode([thenE],function(pulse) { if (testValue &&
(testStamp === pulse.stamp)) { send(pulse); } }),
createNode([elseE],function(pulse) { if (!testValue && (testStamp
=== pulse.stamp)) { send(pulse); } }));
};
The variable 'send' is not defined here... twice. I think both
functions should have formal arguments including 'send' -- I'm
guessing ' function(send,
pulse)'?
I've been experimenting with usage of flapjax in the context of node.js:
https://github.com/ry/node
This involves changing the local copy of flapjax-2.1.js so that references to addEventListener
-> addListener
and removeEventListener
-> removeListener
, per the node.js API.
Also node.js scripts don't have a window
object by default but a stand-in can easily be created: var window = {}
. Then the global setTimeout can be referenced to to the window object: window.setTimeout = setTimeout
.
With those changes in place, flapjax works just fine inside a node.js script:
require('./flapjax-2.1.js')
var myReceiver = receiverE()
...
One thing I have discovered is that while instances of the node.js EventEmitter class can emit an arbitrary number of arguments (i.e. objects) to a callback function, the $E
function in flapjax will pass only one of the emitted objects.
So for example:
require('./flapjax-2.1.js')
var events = require('events')
var myEmitter = new events.EventEmitter()
var myE = $E(myEmitter, 'eventA')
myE.mapE(function (arg1, arg2) { console.log(arg1, arg2) })
myEmitter.emit('eventA', '1', '2')
If I save that script to myScript.js
and run it from bash with node myScript.js
the the following is printed to the terminal: 1 undefined
.
In other words, $E
is effectively ignoring the second argument-object being emitted on eventA
.
Now, I can "fix" it in the following manner:
...
var myR = receiverE()
myEmitter.on('eventA', function (arg1, arg2) {
myR.sendEvent({ arg1 : arg1, arg2 : arg2 })
})
myR.mapE(function (evt) { console.log(evt.arg1, evt.arg2) })
myEmitter.emit('eventA', '1', '2')
When I run it this time I get what I wanted: 1 2
is printed to the terminal.
However, this workaround introduces additional complexity into the program. Certainly, in larger scripts, once the proper receivers have been setup and the emitters "remapped" to $E
, mapE
, etc., one still benefits from the clarity that flapjax brings to reasoning about the evented dataflow.
I'm curious though how hard it would be to adapt flapjax so that it can pass an arbitrary number of emitted objects from an EventEmitter instead of one (the first one) only. I spent an hour+ poking around in the source, looking for some candidate function that I could modify to do just this, but I came up empty handed (so far).
Your thoughts on this would most appreciated.
Uncaught TypeError: Object saveButton has no method 'addEventListener'
I just run the transient draft example on http://www.flapjax-lang.org/demos/transient_drafts.html
and discover this error.
(See screenshot)
Was there ever a solution that would allow for pruning the unused parts of the graph?
This looks really bad for anyone considering using Flapjax.
I'm not sure how else to contact anyone responsible, other than creating an issue here.
To reproduce:
IDs work, I'm not sure why (this is happening in Chrome). It's probably one of those funky DOM interaction things. I wouldn't know about that, since I'm a jQuery lover. This seems to work though:
// line 1368
// was
obj[prop] = val;
// is
obj.setAttribute(prop, val);
Probably should change line 1350 too, to be consistant.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.