@bem-react/di
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -50,18 +50,8 @@ 'use strict'; | ||
function Registry(options) { | ||
this.inverted_ = false; | ||
this.inverted = false; | ||
this.components = new Map(); | ||
this.id_ = options.id; | ||
this.inverted_ = Boolean(options.inverted); | ||
this.id = options.id; | ||
this.inverted = Boolean(options.inverted); | ||
} | ||
Object.defineProperty(Registry.prototype, "id", { | ||
get: function () { return this.id_; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Registry.prototype, "inverted", { | ||
get: function () { return this.inverted_; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Registry.prototype.add = function (id, component) { | ||
Registry.prototype.set = function (id, component) { | ||
this.components.set(id, component); | ||
@@ -71,4 +61,6 @@ }; | ||
var component = this.components.get(id); | ||
if (!component) { | ||
throw new Error("Component with id '" + id + "' not found."); | ||
{ | ||
if (!component) { | ||
throw new Error("Component with id '" + id + "' not found."); | ||
} | ||
} | ||
@@ -75,0 +67,0 @@ return component; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _assign=require("object-assign"),React=require("react"),__assign=function(){return(__assign=_assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return function(t){var e=function(e){return React.createElement(RegistryConsumer,null,function(r){var n={};return i.forEach(function(e){var t=r[e.id];n[e.id]=e.inverted?t||e:e||t}),React.createElement(RegistryProvider,{value:n},React.createElement(t,__assign({},e)))})};return e.displayName="RegistryResolver("+i.map(function(e){return e.id}).join(", ")+")",e}}var Registry=function(){function e(e){this.inverted_=!1,this.components=new Map,this.id_=e.id,this.inverted_=Boolean(e.inverted)}return Object.defineProperty(e.prototype,"id",{get:function(){return this.id_},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inverted",{get:function(){return this.inverted_},enumerable:!0,configurable:!0}),e.prototype.add=function(e,t){this.components.set(e,t)},e.prototype.get=function(e){var t=this.components.get(e);if(!t)throw new Error("Component with id '"+e+"' not found.");return t},e}();exports.RegistryConsumer=RegistryConsumer,exports.withRegistry=withRegistry,exports.Registry=Registry; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _assign=require("object-assign"),React=require("react"),__assign=function(){return(__assign=_assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return function(t){var e=function(e){return React.createElement(RegistryConsumer,null,function(r){var n={};return i.forEach(function(e){var t=r[e.id];n[e.id]=e.inverted?t||e:e||t}),React.createElement(RegistryProvider,{value:n},React.createElement(t,__assign({},e)))})};return e.displayName="RegistryResolver("+i.map(function(e){return e.id}).join(", ")+")",e}}var Registry=function(){function e(e){this.inverted=!1,this.components=new Map,this.id=e.id,this.inverted=Boolean(e.inverted)}return e.prototype.set=function(e,t){this.components.set(e,t)},e.prototype.get=function(e){return this.components.get(e)},e}();exports.RegistryConsumer=RegistryConsumer,exports.withRegistry=withRegistry,exports.Registry=Registry; |
@@ -6,2 +6,11 @@ # Change Log | ||
<a name="0.2.1"></a> | ||
## [0.2.1](https://github.com/bem/bem-react-core/compare/@bem-react/di@0.2.0...@bem-react/di@0.2.1) (2018-08-29) | ||
**Note:** Version bump only for package @bem-react/di | ||
<a name="0.2.0"></a> | ||
@@ -8,0 +17,0 @@ # 0.2.0 (2018-08-29) |
@@ -9,10 +9,8 @@ import * as React from 'react'; | ||
export declare class Registry { | ||
private id_; | ||
private inverted_; | ||
id: string; | ||
inverted: boolean; | ||
private components; | ||
constructor(options: IRegistry); | ||
readonly id: string; | ||
readonly inverted: boolean; | ||
add(id: string, component: React.ComponentType): void; | ||
set(id: string, component: React.ComponentType): void; | ||
get<P>(id?: string): React.ComponentType<P>; | ||
} |
{ | ||
"name": "@bem-react/di", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "BEM React Dependency Injection", | ||
@@ -32,3 +32,3 @@ "repository": { | ||
}, | ||
"gitHead": "7d071c56f6bd11911046baa42001fa240c749fb0" | ||
"gitHead": "38ca8966475df69dfdeb537cf90f74f8fbd1dae3" | ||
} |
5961
90