English sentences that everyone can understand
When I began to learn to write articles, I hesitated. I thought that I could not pass CET-4 and spoken English. Why should I write such articles?
When I saw the students at the front of the beginner's entrance constantly consulting and questioning others, I thought of writing an article to tell those helpless students who want to master the advanced technology but fear the English, you need not be afraid, dawn is coming.
Okay, let's start with a question.
Why are there so many clauses in English?
Why is a simple Chinese sentence written in two parts when translated into English?
Why do attributive clauses have so many related words and types?
Okay, now let's answer these questions one by one.
Angular introduces StaticInjector. Should you care? Recently Angular guys made a commit that introduces Static Injector. It is most likely intended to replace the existing Reflective Injector in the future. Not many of us have used Reflective Injector in our code base directly and even fewer yet understand the intricacies of its internals. So it's not immediately clear what to make of such a change. Why is better? How does it affect my code? Do I need to migrate? These are the questions you might be asking yourself. But not to worry. Me and Alexey Zuev have got everything covered for you. This article will give you the answer you need. Why is ReflectiveInjector reflective? Before we take a look at the new static injector let's spend a few minutes and see how the currently used injector got its name. We will use this this simple example to do that: class B {} class A { constructor(@Inject(B) b) { } } const i = ReflectiveInjector.resolveAndCreate([A, B]); const a = i.get(A); We have two services here A and B and the service A depends on the service B. And when we pass the providers to the resolveAndCreate method we don't specify anywhere that A depends on the B. So how does injector know that? You've probably guessed (or knew) that the secret is in using Inject decorator. This decorator uses the library Reflect to attach some metadata to the class A. I've written in Implementing custom component decorator in Angular how decorators in Angular use this library. Here is the gist of the Inject decorator implementation: function ParamDecorator(cls: any, unusedKey: any, index: number) { ... // parameters here will be [ {token: B} ] Reflect.defineMetadata('parameters', parameters, cls); return cls; } So as you can see when Inject gets executed we have the information about dependencies attached to the class. In turn, when we pass providers to resolveAndCreate method the injector goes through each provider and tries to collect all dependencies using the same Reflect object. It all happens inside resolveReflectiveFactory function that takes a provider and resolves its dependencies: function resolveReflectiveFactory(provider) { // ... if (provider.useClass) { var useClass = resolveForwardRef(provider.useClass); factoryFn = reflector.factory(useClass); resolvedDeps = _dependenciesFor(useClass); } } export class ReflectionCapabilities { ... private _ownParameters(type, parentCtor) { ... // R is Reflect const paramAnnotations = R.getOwnMetadata('parameters', type); } } Now this shows that ReflectiveInjector relies on reflective capabilities currently provided by Reflect shim to extract implicit dependencies.
In the English language shown in the above section, if you take a rough look, you will find the familiar words:
that
it
and
of
when
why
what
in
to
on
......
There are also simple sentences, declarative sentences, interrogative sentences, attributive clauses...
Now, let's briefly review the basic content (due to limited ability, just for a brief analysis, hero, please don't wonder):
Golden Law:
A sentence has only one real subject, which can be a noun, pronoun or a sentence.
A sentence has and has only one predicate
A sentence can not be bare before countable nouns, such as: girl, can be a girl or the girl can not simply write girls.
Distinguish the form of non-predicate and the sentence elements that can be used in a sentence
Remembering the Relevant Words of Attributive Clauses and the Use of Relevant Words
Distinguish the conjunctions of juxtaposed sentences, such as common and, or
To be continued
God's favored one
Thursday, August 10, 2017, Shenzhen is cloudy