Skip to content

Ivy#20855

Closed
mhevery wants to merge 24 commits intoangular:masterfrom
mhevery:ivy
Closed

Ivy#20855
mhevery wants to merge 24 commits intoangular:masterfrom
mhevery:ivy

Conversation

@mhevery
Copy link
Copy Markdown
Contributor

@mhevery mhevery commented Dec 7, 2017

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[X] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

@mhevery mhevery force-pushed the ivy branch 4 times, most recently from 4afc8c1 to 7e72330 Compare December 7, 2017 06:33
@jasonaden jasonaden added the area: core Issues related to the framework runtime label Dec 7, 2017
@mhevery mhevery force-pushed the ivy branch 6 times, most recently from 6cc948b to 43e60fa Compare December 7, 2017 20:50
@mhevery mhevery added the target: major This PR is targeted for the next major release label Dec 7, 2017
@mhevery mhevery requested a review from kara December 7, 2017 21:03
Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review all the .ts code

Comment thread package.json Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

Comment thread package.json Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not, reverted

Comment thread packages/core/src/render3/assert.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this file in core/src/render3 ? shouldn't it be in a more common location?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move it later, right now just keeping it in sync with Ivy repository

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t -> to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdoc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread packages/core/src/render3/index.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crating -> creating

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread packages/core/src/render3/index.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you add a trailing comma, the formatter will put one-per-line as you want

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread packages/core/test/BUILD.bazel Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed, because glob should not descend into subpackages.
Apparently it's broken in bazel 0.8 but will be fixed in next release, according to bazelbuild/bazel#4242

Comment thread packages/core/test/render3/BUILD.bazel Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omit srcs, it's no longer required

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread packages/platform-server/BUILD.bazel Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to change platform-server?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

@mhevery mhevery force-pushed the ivy branch 2 times, most recently from 2ba4572 to 8c5c14d Compare December 7, 2017 23:04
@mhevery
Copy link
Copy Markdown
Contributor Author

mhevery commented Dec 7, 2017 via email

@mhevery mhevery force-pushed the ivy branch 4 times, most recently from bd8d43b to 6e0ab34 Compare December 8, 2017 06:07
Comment thread packages/core/src/render3/assert.ts Outdated
(actual < expected) && assertThrow(actual, expected, condition, '>');
}

export function assertNotNull<T>(actual: T, condition: string) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad name

@mhevery mhevery requested review from IgorMinar and jelbourn December 8, 2017 19:07
Copy link
Copy Markdown
Contributor

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got just a small ways through before a meeting- I'll come back for the rest afterwards

*/

function stringify(value: any) {
return typeof value === 'string' ? `"${value}"` : '' + value;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add an explanation (function description) for why string get wrapped in an additional set of " but other types don't?
  • stringify isn't a great name because of that extra behavior of adding the " (vs. only coercing the type to string). Could the name be more specific?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybestringifyWithQuotes ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about stringifyValueForDisplay or stringifyValueForError?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, let's do stringifyValueForError then

* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a file-level comment that provides some context on the functions contained within? (what they're meant to be used for)

(actual == expected) && assertThrow(actual, expected, condition, '!=');
}

export function assertThrow<T>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add JsDoc description block for this? It's not immediately obvious what condition, operator, and serializer are from just looking at this function.

(Ideally I'd like to see description on all the functions, but I'd acknowledge the rest are mostly self-explanatory)

Comment thread packages/core/src/render3/component.ts Outdated
/**
* Options which control how the component should be bootstrapped.
*/
export interface CreateComponentOptionArgs {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always for bootstrapping? If so, what about ComponentBootstrapConfig or ComponentBootstrapOptions?

If it's any creation, ComponentCreationConfig or ComponentCreationOptions?

It's not immediately clear what is meant by "OptionArgs".

Comment thread packages/core/src/render3/component.ts Outdated
export interface CreateComponentOptionArgs {
/**
* Which renderer to use.
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: short JsDoc can be collapsed to a single line

/** Renderer instance used for the created component. */
renderer?: Renderer3;

This increases in information density of the file, making it easier to read more at once without scrolling.

throw new Error('NotImplemented');
}

function addDestroyable<T, C>(obj: any, context: C): T&DestroyRef<C> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add function description, especially for the params (obj: any could be anything).

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an arrow function?

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createComponentRef has the same description- change this function's description to be more specific about what it does?

Copy link
Copy Markdown
Contributor

@kara kara Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit confusing because createComponentRef wraps renderComponent, so technically createComponentRef also does what's in here. The difference is really the return value. I'll update the comment.

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NgComponent is a lightweight API for bootstrapping and for interacting with the
bootstrapped component. The API is inspired by the native Custom Element API.

This functions returns T, not an NgComponent? Should there be a comment here to explain what's up with that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I believe that comment is out of date. It should say that it returns an instance of the component.

Comment thread packages/core/src/render3/component.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment that explains which error you're targeting with this try? Might also be good to comment on why try is okay here WRT potential VM optimization issues.

Copy link
Copy Markdown
Contributor

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of steam for today. Will come back for more.

Comment thread packages/core/src/render3/interfaces.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break this file up into more specific indivual files? Having one interface per file would probably be overkill, but breaking them up into smaller chunks would probably make this easier to navigate.

const ngDevMode: boolean;
}

export const enum LNodeFlags {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what these are and how they're used? Also, these seems to be a mix of flags, masks, and constants (the shifts), which is slightly odd.

Comment thread packages/core/src/render3/interfaces.ts Outdated
/**
* NOTES:
*
* Each Array costs 70 bytes and is composed of `Array` and `(array)` object
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this note in reference to? It seems like it's describing a pattern somewhere in this file but it's not clear what exactly it's referring to.

Copy link
Copy Markdown
Contributor

@kara kara Dec 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a general note to remind us of the cost when choosing between objects and arrays in the design phase. Where do you think a better place would be for it to go? It does seem out of place here, but don't know where to put it.

Comment thread packages/core/src/render3/interfaces.ts Outdated
/**
* `ViewState` stores all of the information needed to process the instructions as
* they are invoked from the template. `ViewState` is saved when a child `View` is
* being processed and restored when the child `View` is done.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not what clear on what's meant by "saved" vs. "restored" here

Comment thread packages/core/src/render3/interfaces.ts Outdated
* need this to be able to efficiently find the `LView` when inserting the
* view into an anchor.
*/
readonly node: LView|LElement;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment says LView, but type says LView|LElement. Clarify?

Also, why not rootNode?

values: any[];
}

export class QueryState_ implements QueryState {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind having an interface when the concrete class is going to be QueryState_? Why not just have the implementation as QueryState and skip the interface? Without knowing the rationale it feels like an unnecessary level of indirection.

Comment thread packages/core/src/render3/query.ts Outdated
*/

import {Observable} from 'rxjs/Observable';
import {QueryList as IQueryList, Type} from '../core';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment here explaining the alias?

@@ -0,0 +1,293 @@
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More consistent function descriptions throughout this file?

@@ -0,0 +1,156 @@
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function descriptions through this file?

Comment thread packages/core/src/render3/di.ts Outdated
* found in the LICENSE file at https://angular.io/license
*/

import {ComponentFactory, ComponentRef as IComponentRef, ElementRef as IElementRef, EmbeddedViewRef as IEmbeddedViewRef, Injector, NgModuleRef as INgModuleRef, TemplateRef as ITemplateRef, Type, ViewContainerRef as IViewContainerRef, ViewRef as IViewRef} from '../core';
Copy link
Copy Markdown
Contributor

@jelbourn jelbourn Dec 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment explaining aliases here?

Would it make sense to pattern these aliases like LegacyComponentRef, LegacyElementRef, etc.? Just prefixing with an I doesn't make the code any more clear, it just mixes up the concept of prefixing all interfaces with I

@mhevery mhevery force-pushed the ivy branch 2 times, most recently from 80e9bd4 to 2b00efd Compare December 21, 2017 00:29
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
This PR fixes a circular dependency among those files in Renderer3:
`query` -> `di` -> `instructions` -> `query` -> ...

Looking at the above dependencies the `di` -> `instructions` import is
a problematic one. Previously `di` had an import from `instructions`
since we can known about "current node" only in `instructions`
(and we need "current node" to create node injector instances).

This commit refactors the code in the way that functions in the
`di` file don't depend on any info stored module-global variables
in `instructions`.

PR Close #20855
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
IgorMinar pushed a commit that referenced this pull request Dec 22, 2017
@IgorMinar IgorMinar closed this in 0fa818b Dec 22, 2017
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.