Skip to content

Instantly share code, notes, and snippets.

@matthewrobb
Last active August 29, 2015 14:02
Show Gist options
  • Save matthewrobb/48f3aaf3df0370163f49 to your computer and use it in GitHub Desktop.
Save matthewrobb/48f3aaf3df0370163f49 to your computer and use it in GitHub Desktop.
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);
}
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