diff --git a/docs/api.md b/docs/api.md index ee6b139..1d228ce 100644 --- a/docs/api.md +++ b/docs/api.md @@ -134,33 +134,23 @@ assign(A, 10); console.log(resolve(A)); // 10 ``` -## isolate +## zone -Run your app in isolated Dependency Injection scope. All instances cached for this instance application will be isolated from all cached instances in other scopes. All overrides defined here will be inherited for nested isolated scopes but not available for others. The return value can be object, function, or any other value: -- For object. All methods will be proxied and their return values converted to promises of them -- For function. The function will be proxied and return value converted to promise of it. -- For any value. Return it value without any changes +Run your app in isolated Dependency Injection scope. All instances cached for this instance application will be isolated from all cached instances in other scopes. All overrides defined here will be inherited for nested isolated scopes but not available for others. No return value. ```javascript -const proxy = await isolate(() => { +await zone(async () => { const app = new App(); // Run you app here + await app.run(); // ... - return { - methodA() {}, - methodB() {}, - // ... - } }); -// ... -await proxy.methodA(); -await proxy.methodB(); ``` ```javascript -await isolate(async () => { +await zone(async () => { override(Dep1, Dep2); - await isolate(async () => { + await zone(async () => { override(Dep2, Dep3); // ... console.log(resolve(Dep1) instanceof Dep3); // true diff --git a/docs/index.md b/docs/index.md index 83f4b2b..98b5f8a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,12 +6,6 @@ sidebar_label: Getting Started Async context based Dependency Injection for Node.JS without pain with Dependency Injection Container, dependency registration, and configuration. -- You can use it at any place of your application without rewrite your applications architecture or other preparations or initializations. -- Each dependency can be class, function, or any another value, and plain JavaScript object too. -- You can override your dependencies for organizing modules architecture, or unit testing without hack standard Node.JS require mechanism. -- You can use TypeScript or JavaScript, with decorators or not. Different syntaxes for one mechanism. You can use the constructor to provide dependencies or not, as you wish. -- You can create isolate context for multiple instances of your application (Dependency Injection scopes) with a different set of dependencies, overrides, and instances. - @@ -155,4 +149,10 @@ new App().start(); // You can create an instance directly as usually class -If you have questions or something else for me or this project, maybe architectures questions, improvement ideas or anything else, please make the issue. +- You can use it at any place of your application without rewrite your applications architecture or other preparations or initializations. +- Each dependency can be class, function, or any another value, and plain JavaScript object too. +- You can override your dependencies for organizing modules architecture, or unit testing without hack standard Node.JS require mechanism. +- You can use TypeScript or JavaScript, with decorators or not. Different syntaxes for one mechanism. You can use the constructor to provide dependencies or not, as you wish. +- You can create isolate context for multiple instances of your application (Dependency Injection scopes) with a different set of dependencies, overrides, and instances. + +If you have questions or something else for me or this project, maybe architectures questions or improvement ideas, please make the issue in github. diff --git a/website/pages/en/index.js b/website/pages/en/index.js deleted file mode 100644 index 1d4fe8c..0000000 --- a/website/pages/en/index.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const React = require('react'); - -// const CompLibrary = require('../../core/CompLibrary.js'); - -// const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ -// const Container = CompLibrary.Container; -// const GridBlock = CompLibrary.GridBlock; - - -class Index extends React.Component { - render() { - const {config: siteConfig, language = ''} = this.props; - const {baseUrl, docsUrl} = siteConfig; - const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`; - const langPart = `${language ? `${language}/` : ''}`; - const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`; - - const PromoSection = props => ( -
-
-
{props.children}
-
-
- ); - - const Button = props => ( -
- - {props.children} - -
- ); - - - return ( -
-
- -
-
-
-
-
-

- {siteConfig.tagline} -

- - - -
-
-
-
-
-
-
- ); - } -} - -module.exports = Index; diff --git a/website/sidebars.json b/website/sidebars.json index 5785dd0..f283a90 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -6,7 +6,7 @@ "examples", "overrides", "unit-testing", - "isolate", + "zone", "api" ] } diff --git a/website/static/index.html b/website/static/index.html new file mode 100644 index 0000000..a9f4d6a --- /dev/null +++ b/website/static/index.html @@ -0,0 +1,18 @@ + + + + + + + node-provide + + + If you are not redirected automatically, follow this + link. + +