wangbinyq / personal-wiki

2 stars 0 forks source link

MV* 框架 #10

Open wangbinyq opened 8 years ago

wangbinyq commented 8 years ago

Backbone

wangbinyq commented 7 years ago

Preact

source code structure:

https://medium.com/@rajaraodv/the-inner-workings-of-virtual-dom-666ee7ad47cf

wangbinyq commented 5 years ago

Angular

Dependency Injection

Module

Injector

var fn = function (a , b) { return a + b } fn.$inject = ['a', 'b'] injector.invoke(fn) === 42

- invoke a function with local variables
- instantiating objects
```js
function Type (a, b) {
  this.result = a + b
}

Type.$inject = ['a', 'b']
injector.instantiate(Type).result === 42

Provider

injector.get('a') === 42

- provider can be injected?
```js
module.provider('b', {$get: function (a) { return a + 2} })
module.provider('a', {$get: function () { return 40 }}

injector.get('b') === 42