refactor(AppViewListener): prefix listener with on for consistency
Closes #3925
This commit is contained in:
parent
608cdc4077
commit
04b4035ecd
|
@ -50,7 +50,7 @@ export class DebugElementViewListener implements AppViewListener {
|
|||
DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
|
||||
}
|
||||
|
||||
viewCreated(view: AppView) {
|
||||
onViewCreated(view: AppView) {
|
||||
var viewId = _nextId++;
|
||||
_allViewsById.set(viewId, view);
|
||||
_allIdsByView.set(view, viewId);
|
||||
|
@ -60,7 +60,7 @@ export class DebugElementViewListener implements AppViewListener {
|
|||
}
|
||||
}
|
||||
|
||||
viewDestroyed(view: AppView) {
|
||||
onViewDestroyed(view: AppView) {
|
||||
var viewId = _allIdsByView.get(view);
|
||||
_allIdsByView.delete(view);
|
||||
_allViewsById.delete(viewId);
|
||||
|
|
|
@ -6,6 +6,6 @@ import * as viewModule from './view';
|
|||
*/
|
||||
@Injectable()
|
||||
export class AppViewListener {
|
||||
viewCreated(view: viewModule.AppView) {}
|
||||
viewDestroyed(view: viewModule.AppView) {}
|
||||
onViewCreated(view: viewModule.AppView) {}
|
||||
onViewDestroyed(view: viewModule.AppView) {}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ export class AppViewManager_ extends AppViewManager {
|
|||
this._renderer.detachFragment(hostView.renderFragment);
|
||||
this._renderer.dehydrateView(hostView.render);
|
||||
this._viewDehydrateRecurse(hostView);
|
||||
this._viewListener.viewDestroyed(hostView);
|
||||
this._viewListener.onViewDestroyed(hostView);
|
||||
this._renderer.destroyView(hostView.render);
|
||||
wtfLeave(s);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ export class AppViewManager_ extends AppViewManager {
|
|||
var mergedParentView =
|
||||
this._utils.createView(protoView, renderViewWithFragments, this, this._renderer);
|
||||
this._renderer.setEventDispatcher(mergedParentView.render, mergedParentView);
|
||||
this._viewListener.viewCreated(mergedParentView);
|
||||
this._viewListener.onViewCreated(mergedParentView);
|
||||
return mergedParentView;
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ export class AppViewManager_ extends AppViewManager {
|
|||
_destroyPooledView(view: viewModule.AppView) {
|
||||
var wasReturned = this._viewPool.returnView(view);
|
||||
if (!wasReturned) {
|
||||
this._viewListener.viewDestroyed(view);
|
||||
this._viewListener.onViewDestroyed(view);
|
||||
this._renderer.destroyView(view.render);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ export function main() {
|
|||
function wrapView(view: AppView): ViewRef { return new ViewRef_(view); }
|
||||
|
||||
function resetSpies() {
|
||||
viewListener.spy('viewCreated').reset();
|
||||
viewListener.spy('viewDestroyed').reset();
|
||||
viewListener.spy('onViewCreated').reset();
|
||||
viewListener.spy('onViewDestroyed').reset();
|
||||
renderer.spy('createView').reset();
|
||||
renderer.spy('destroyView').reset();
|
||||
renderer.spy('createRootHostView').reset();
|
||||
|
@ -120,7 +120,7 @@ export function main() {
|
|||
var rootView =
|
||||
internalView(<ViewRef>manager.createRootHostView(wrapPv(hostProtoView), null, null));
|
||||
expect(rootView.proto).toBe(hostProtoView);
|
||||
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(rootView);
|
||||
expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(rootView);
|
||||
});
|
||||
|
||||
it('should hydrate the view', () => {
|
||||
|
@ -178,7 +178,7 @@ export function main() {
|
|||
it('should destroy the render view', () => {
|
||||
manager.destroyRootHostView(wrapView(hostView));
|
||||
expect(renderer.spy('destroyView')).toHaveBeenCalledWith(hostRenderViewRef);
|
||||
expect(viewListener.spy('viewDestroyed')).toHaveBeenCalledWith(hostView);
|
||||
expect(viewListener.spy('onViewDestroyed')).toHaveBeenCalledWith(hostView);
|
||||
});
|
||||
|
||||
it('should not return the view to the pool', () => {
|
||||
|
@ -223,7 +223,7 @@ export function main() {
|
|||
internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef));
|
||||
expect(childView.proto).toBe(childProtoView);
|
||||
expect(childView).toBe(hostView.views[2]);
|
||||
expect(viewListener.spy('viewCreated')).not.toHaveBeenCalled();
|
||||
expect(viewListener.spy('onViewCreated')).not.toHaveBeenCalled();
|
||||
expect(renderer.spy('createView')).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -264,7 +264,7 @@ export function main() {
|
|||
internalView(manager.createEmbeddedViewInContainer(vcRef, 1, templateRef));
|
||||
expect(childView.proto).toBe(childProtoView);
|
||||
expect(childView).not.toBe(firstChildView);
|
||||
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(childView);
|
||||
expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(childView);
|
||||
expect(renderer.spy('createView'))
|
||||
.toHaveBeenCalledWith(childProtoView.render,
|
||||
childProtoView.mergeInfo.embeddedViewCount + 1);
|
||||
|
@ -309,7 +309,7 @@ export function main() {
|
|||
internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef));
|
||||
expect(childView.proto).toBe(childProtoView);
|
||||
expect(childView).toBe(hostView.views[2]);
|
||||
expect(viewListener.spy('viewCreated')).not.toHaveBeenCalled();
|
||||
expect(viewListener.spy('onViewCreated')).not.toHaveBeenCalled();
|
||||
expect(renderer.spy('createView')).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -329,7 +329,7 @@ export function main() {
|
|||
<ViewRef>manager.createHostViewInContainer(vcRef, 0, wrapPv(newHostPv), null));
|
||||
expect(newHostView.proto).toBe(newHostPv);
|
||||
expect(newHostView).not.toBe(hostView.views[2]);
|
||||
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(newHostView);
|
||||
expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(newHostView);
|
||||
expect(renderer.spy('createView'))
|
||||
.toHaveBeenCalledWith(newHostPv.render, newHostPv.mergeInfo.embeddedViewCount + 1);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue