Skip to content

Commit

Permalink
Merge pull request #47 from thefill/feature/ChangeServiceExport
Browse files Browse the repository at this point in the history
Feature/change service export
  • Loading branch information
thefill committed May 21, 2019
2 parents fb1110a + 3b5d17d commit bac1ce1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 73 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Jetli allows you to inject consistently classes, functions and primitives across

Injecting instances of classes is trivial with jetli - just use 'get' method without any additional options.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -78,7 +78,7 @@ Functions, already instantiated objects or primitive values like array, string a

Registration is provided via 'set' method and requires you to provide string token that identifies the injectable element.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -101,7 +101,7 @@ fighter2.punch();</pre>

As explained in previous example primitives can be easily used across your applications with associated string id provided during registration.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

const someNumber = 123;
const someString = 'punch';
Expand All @@ -124,7 +124,7 @@ console.log(injectedArray);</pre>

To use Jetli to full extend implement services that expose init method. This method is the safest place to use Jelit injector inside injectable services.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

jetli.set('someNumber', 123);

Expand All @@ -151,7 +151,7 @@ fighter2.punch();</pre>

Have enough of overhead when all those services initialises at once? Register them and request initialisation only when injection is requested.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -174,7 +174,7 @@ fighter2.punch();</pre>

### Pass arguments to services constructor

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(id){
Expand All @@ -198,7 +198,7 @@ fighter2.punch();</pre>

Jetli uses battle-tested method to fight 'cyclic dependencies' - optional initialisation callback. Injector searches for optional init method to call it and as an argument to provide instance of injector itself. This method provide safe moment to inject all dependencies required by service - you can be sure that all dependencies will be already initialised.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class ServiceA {
init(jetli){
Expand Down Expand Up @@ -240,7 +240,7 @@ serviceB.getId();</pre>

Its rather trivial to mock module dependencies if you have total control whats injected where, right? ith Jetli you can reset any previously registered/injected dependencies and introduce your own mocks / stubs.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand Down
52 changes: 0 additions & 52 deletions TODO.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetli",
"version": "0.0.7",
"version": "1.0.0",
"description": "Dependency injector",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
16 changes: 8 additions & 8 deletions src/docs-partials/readme.body.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Jetli allows you to inject consistently classes, functions and primitives across

Injecting instances of classes is trivial with jetli - just use 'get' method without any additional options.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -60,7 +60,7 @@ Functions, already instantiated objects or primitive values like array, string a

Registration is provided via 'set' method and requires you to provide string token that identifies the injectable element.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -83,7 +83,7 @@ fighter2.punch();</pre>

As explained in previous example primitives can be easily used across your applications with associated string id provided during registration.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

const someNumber = 123;
const someString = 'punch';
Expand All @@ -106,7 +106,7 @@ console.log(injectedArray);</pre>

To use Jetli to full extend implement services that expose init method. This method is the safest place to use Jelit injector inside injectable services.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

jetli.set('someNumber', 123);

Expand All @@ -133,7 +133,7 @@ fighter2.punch();</pre>

Have enough of overhead when all those services initialises at once? Register them and request initialisation only when injection is requested.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand All @@ -156,7 +156,7 @@ fighter2.punch();</pre>

### Pass arguments to services constructor

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(id){
Expand All @@ -180,7 +180,7 @@ fighter2.punch();</pre>

Jetli uses battle-tested method to fight 'cyclic dependencies' - optional initialisation callback. Injector searches for optional init method to call it and as an argument to provide instance of injector itself. This method provide safe moment to inject all dependencies required by service - you can be sure that all dependencies will be already initialised.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class ServiceA {
init(jetli){
Expand Down Expand Up @@ -222,7 +222,7 @@ serviceB.getId();</pre>

Its rather trivial to mock module dependencies if you have total control whats injected where, right? ith Jetli you can reset any previously registered/injected dependencies and introduce your own mocks / stubs.

<pre class="runkit-source">const jetli = require('jetli@0.0.6').jetli;
<pre class="runkit-source">const jetli = require('jetli@0.0.8').jetli;

class Attack {
constructor(){
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// Export classes and interfaces just in case
export * from './interfaces';
export * from './classes';

// make service exported as default for the easiness of usage
import {jetli} from './services';
export default jetli;
export * from './services';

0 comments on commit bac1ce1

Please sign in to comment.