Giter Site home page Giter Site logo

jeniturtle / egg-async-loader-framework Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3 KB

对egg生命周期中的configWillLoad方法做了同步处理,支持异步获取远程配置文件之后,动态修改配置文件,然后再继续执行configDidLoad,并且在configDidLoad之前会加载所有插件addSingleton的creator方法。

JavaScript 100.00%

egg-async-loader-framework's Introduction

框架介绍


功能说明:

对egg生命周期中的configWillLoad方法做了同步处理,支持异步获取远程配置文件之后,动态修改配置文件,然后再继续执行configDidLoad,并且在configDidLoad之前会加载所有插件addSingleton的creator方法。

如果有的插件没使用addSingleton方法创建实例,需要在获取配置文件之后,手动调用。

注意事项:

注意:egg框架的loader设定 willReady、didReady、serverDidReady这几个生命周期,强制在同步之前执行,所以willReady不会等待前面的生命周期执行完,而是在configWillLoader执行同步操作的同时去执行,这时同步操作并没有执行完,而且插件也没有开始加载,所以这里导致生命周期跟egg框架有出入,但是没得办法。。。核心代码无法被重写,这里只能强行获取Symbol私有属性,去覆盖之前的逻辑。

使用方法

一、安装

npm install egg-async-loader-framework

二、引用

修改引用项目的package.json文件,在文件中加入:

...
"egg": {
    ...
    "framework": "egg-async-loader-framework"
  },
...

egg-async-loader-framework's People

Contributors

jeniturtle avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.