Last active
August 29, 2015 14:02
-
-
Save matthewrobb/48f3aaf3df0370163f49 to your computer and use it in GitHub Desktop.
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
import { odd as local_odd } from "./b"; | |
export var counter = 0; | |
export default function even(n) { | |
console.log("even has run %s times", counter++); | |
return n === 0 || local_odd(n - 1); | |
} |
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
System.register("tests/others/a", function($import_bind, $export_bind, $export_push) { | |
return { | |
deps: [ "./b" ], | |
execute: function() { | |
"use strict"; | |
var local_odd, counter; | |
// m.setup(...dep_configs, exports) | |
$import_bind("odd", function($cur){ local_odd = $cur }); | |
$export_bind("default", function(){ return even }); | |
$export_bind("counter", function(){ return counter }); | |
/* begin source body */ | |
$export_push("counter", counter = 0); // push to importers, return argument[1] | |
function even(n) { | |
console.log("even has run %s times", $export_push("counter", counter++)); | |
return n === 0 || local_odd(n - 1); | |
} | |
} | |
}; | |
}); | |
// This is what the push operation would sort-of look like | |
meta.execute.push = function(name, pass_through) { | |
var newVal = my.exports[name](); // fetch the value to push from the export_binding | |
// push newVal out to subscribers of `name` | |
return pass_through; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment