Skip to content

Instantly share code, notes, and snippets.

@young-steveo

young-steveo/container.js Secret

Created Feb 12, 2016
Embed
What would you like to do?
import Bottle from "../bottle.js";
import Proxy from "../node_modules/harmony-proxy/index.js";
import Fuel from "./Fuel.js";
import Engine from "./Engine.js";
import Car from "./Car.js";
class handler {
static get(bottle, name){
return bottle.container[name];
}
};
let bottle = new Bottle();
bottle.constant('GASOLINE', 'Gasoline');
bottle.constant('DIESEL', 'Diesel');
bottle.constant('V6', 'v6');
bottle.constant('V12', 'v12');
bottle.service('Gasoline', Fuel, 'GASOLINE');
bottle.service('Diesel', Fuel, 'DIESEL');
bottle.service('DieselEngine', Engine, 'V6', 'Diesel');
bottle.service('GasolineEngine', Engine, 'V12', 'Gasoline');
bottle.service('Toyota', Car, 'DieselEngine');
bottle.service('Ferrari', Car, 'GasolineEngine');
export default new Proxy(bottle, handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.