GithubHelp home page GithubHelp logo

brownplt / flapjax Goto Github PK

View Code? Open in Web Editor NEW
232.0 232.0 12.0 7.74 MB

functional reactive programming for JavaScript

Home Page: http://www.flapjax-lang.org/

License: BSD 3-Clause "New" or "Revised" License

Haskell 26.55% Shell 0.35% JavaScript 71.98% CSS 1.12%

flapjax's People

Contributors

exelian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flapjax's Issues

getWebServiceObjectE doesn't notify if an error occured

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.

ifE is broken

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)'?

Node.js adaptation - EventEmitters pass multiple arguments

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.

Garbage Collection

Was there ever a solution that would allow for pruning the unused parts of the graph?

flapjax-lang.org is down

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.

Giving Classes to Time-varying DOM Elements is broken

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.

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.