Skip to content

Commit

Permalink
Fixed example code
Browse files Browse the repository at this point in the history
  • Loading branch information
singintime committed Sep 6, 2022
1 parent cc4e49b commit 96b4123
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ const C_TOKEN = new InjectionToken("C_TOKEN")
// Class respecting the Injectable contract:
class A {
constructor(dependencies: {b: {x: string, y: string}, c: number})
constructor(dependencies: {b: {x: string, y: string}, c: number}) {}
static inject = {b: B_TOKEN, c: C_TOKEN}
}
// Providers map tokens to dependency resolvers.
// Injectable classes, factory methods, and concrete instances are supported.
const providerA = {provide: A_TOKEN, useClass: A}
const providerB = {provide: B_TOKEN, useFactory: () => {x: "foo", y: "bar"}}
const providerB = {provide: B_TOKEN, useFactory: () => ({x: "foo", y: "bar"})}
const providerC = {provide: C_TOKEN, useValue: 42}
// Injectors are used to register providers, and resolve instances
Expand Down
11 changes: 2 additions & 9 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
--dark-hl-6: #4EC9B0;
--light-hl-7: #001080;
--dark-hl-7: #9CDCFE;
--light-hl-8: #000000;
--dark-hl-8: #C8C8C8;
--light-hl-9: #098658;
--dark-hl-9: #B5CEA8;
--light-hl-8: #098658;
--dark-hl-8: #B5CEA8;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}
Expand All @@ -33,7 +31,6 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
} }

Expand All @@ -47,7 +44,6 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
} }

Expand All @@ -61,7 +57,6 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
}

Expand All @@ -75,7 +70,6 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
}

Expand All @@ -88,5 +82,4 @@
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
pre, code { background: var(--code-background); }
6 changes: 3 additions & 3 deletions docs/classes/InjectionToken.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">InjectionToken</span></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injection-token.ts#L5">injection-token.ts:5</a></li></ul></aside>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injection-token.ts#L5">injection-token.ts:5</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand Down Expand Up @@ -62,14 +62,14 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>name: <span class="tsd-signature-type">string</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injection-token.ts#L6">injection-token.ts:6</a></li></ul></aside></li></ul></section></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injection-token.ts#L6">injection-token.ts:6</a></li></ul></aside></li></ul></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="name" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagReadonly">Readonly</code> <span>name</span><a href="#name" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<div class="tsd-signature">name<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injection-token.ts#L6">injection-token.ts:6</a></li></ul></aside></section></section></div>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injection-token.ts#L6">injection-token.ts:6</a></li></ul></aside></section></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
16 changes: 8 additions & 8 deletions docs/classes/Injector.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">Injector</span></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L8">injector.ts:8</a></li></ul></aside>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L8">injector.ts:8</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand Down Expand Up @@ -58,12 +58,12 @@ <h2>Properties</h2>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <span>instances</span><a href="#instances" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<div class="tsd-signature">instances<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol">&lt;</span><a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L10">injector.ts:10</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L10">injector.ts:10</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-private"><a id="providers" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <span>providers</span><a href="#providers" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<div class="tsd-signature">providers<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol">&lt;</span><a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">, </span><a href="../types/Provider.html" class="tsd-signature-type" data-tsd-kind="Type alias">Provider</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L9">injector.ts:9</a></li></ul></aside></section></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L9">injector.ts:9</a></li></ul></aside></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private"><a id="createInstance" class="tsd-anchor"></a>
Expand Down Expand Up @@ -91,7 +91,7 @@ <h5>ctor: <a href="../interfaces/Injectable.html" class="tsd-signature-type" dat
<h5>resolved: <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">U</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L90">injector.ts:90</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L90">injector.ts:90</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="register" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>register</span><a href="#register" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
Expand Down Expand Up @@ -119,7 +119,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>provider: <a href="../types/Provider.html" class="tsd-signature-type" data-tsd-kind="Type alias">Provider</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">U</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">V</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L18">injector.ts:18</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L18">injector.ts:18</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="resolve" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>resolve</span><a href="#resolve" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
Expand All @@ -142,7 +142,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>token: <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L40">injector.ts:40</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L40">injector.ts:40</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private"><a id="resolveInstance" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <span>resolve<wbr/>Instance</span><a href="#resolveInstance" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private">
Expand All @@ -167,7 +167,7 @@ <h5>token: <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kin
<h5>resolved: <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L48">injector.ts:48</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L48">injector.ts:48</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="unregister" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>unregister</span><a href="#unregister" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
Expand All @@ -190,7 +190,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>token: <a href="InjectionToken.html" class="tsd-signature-type" data-tsd-kind="Class">InjectionToken</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/b824199/src/injector.ts#L31">injector.ts:31</a></li></ul></aside></li></ul></section></section></div>
<li>Defined in <a href="https://github.com/singintime/vodit/blob/cc4e49b/src/injector.ts#L31">injector.ts:31</a></li></ul></aside></li></ul></section></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
Loading

0 comments on commit 96b4123

Please sign in to comment.