Created
October 2, 2011 04:02
-
-
Save michaelsbradleyjr/1257025 to your computer and use it in GitHub Desktop.
A very small (and trivial) sample of Jolt in action
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
Jolt = require 'Jolt' | |
Jolt.globalize() # places the Jolt API, _, and EventEmitter in the global scope | |
# Jolt embeds the cross-platform EventEmitter2 library, aliased as EventEmitter | |
myEmitter = new EventEmitter | |
myB = $B ($E myEmitter, 'event').mapE((x, y, z) -> | |
[z, y, x]).nary(true), 0, 0, 0 # initial Behavior value set beyond 1st argument position | |
liftB ((a, b, c) -> | |
console.log a, b, c), myB # produce some side effect | |
# '0 0 0' should have been reported in the console, and now... | |
myEmitter.emit 'event', 1, 2, 3 | |
# '3 2 1' should be reported in the console |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will gist-comments appear in my posterous blog? (testing...)