refactor(AppViewListener): prefix listener with on for consistency

Closes #3925
This commit is contained in:
Victor Berchet 2015-08-31 16:47:50 -07:00
parent 608cdc4077
commit 04b4035ecd
4 changed files with 15 additions and 15 deletions

View File

@ -50,7 +50,7 @@ export class DebugElementViewListener implements AppViewListener {
DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement); DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
} }
viewCreated(view: AppView) { onViewCreated(view: AppView) {
var viewId = _nextId++; var viewId = _nextId++;
_allViewsById.set(viewId, view); _allViewsById.set(viewId, view);
_allIdsByView.set(view, viewId); _allIdsByView.set(view, viewId);
@ -60,7 +60,7 @@ export class DebugElementViewListener implements AppViewListener {
} }
} }
viewDestroyed(view: AppView) { onViewDestroyed(view: AppView) {
var viewId = _allIdsByView.get(view); var viewId = _allIdsByView.get(view);
_allIdsByView.delete(view); _allIdsByView.delete(view);
_allViewsById.delete(viewId); _allViewsById.delete(viewId);

View File

@ -6,6 +6,6 @@ import * as viewModule from './view';
*/ */
@Injectable() @Injectable()
export class AppViewListener { export class AppViewListener {
viewCreated(view: viewModule.AppView) {} onViewCreated(view: viewModule.AppView) {}
viewDestroyed(view: viewModule.AppView) {} onViewDestroyed(view: viewModule.AppView) {}
} }

View File

@ -251,7 +251,7 @@ export class AppViewManager_ extends AppViewManager {
this._renderer.detachFragment(hostView.renderFragment); this._renderer.detachFragment(hostView.renderFragment);
this._renderer.dehydrateView(hostView.render); this._renderer.dehydrateView(hostView.render);
this._viewDehydrateRecurse(hostView); this._viewDehydrateRecurse(hostView);
this._viewListener.viewDestroyed(hostView); this._viewListener.onViewDestroyed(hostView);
this._renderer.destroyView(hostView.render); this._renderer.destroyView(hostView.render);
wtfLeave(s); wtfLeave(s);
} }
@ -390,7 +390,7 @@ export class AppViewManager_ extends AppViewManager {
var mergedParentView = var mergedParentView =
this._utils.createView(protoView, renderViewWithFragments, this, this._renderer); this._utils.createView(protoView, renderViewWithFragments, this, this._renderer);
this._renderer.setEventDispatcher(mergedParentView.render, mergedParentView); this._renderer.setEventDispatcher(mergedParentView.render, mergedParentView);
this._viewListener.viewCreated(mergedParentView); this._viewListener.onViewCreated(mergedParentView);
return mergedParentView; return mergedParentView;
} }
@ -409,7 +409,7 @@ export class AppViewManager_ extends AppViewManager {
_destroyPooledView(view: viewModule.AppView) { _destroyPooledView(view: viewModule.AppView) {
var wasReturned = this._viewPool.returnView(view); var wasReturned = this._viewPool.returnView(view);
if (!wasReturned) { if (!wasReturned) {
this._viewListener.viewDestroyed(view); this._viewListener.onViewDestroyed(view);
this._renderer.destroyView(view.render); this._renderer.destroyView(view.render);
} }
} }

View File

@ -62,8 +62,8 @@ export function main() {
function wrapView(view: AppView): ViewRef { return new ViewRef_(view); } function wrapView(view: AppView): ViewRef { return new ViewRef_(view); }
function resetSpies() { function resetSpies() {
viewListener.spy('viewCreated').reset(); viewListener.spy('onViewCreated').reset();
viewListener.spy('viewDestroyed').reset(); viewListener.spy('onViewDestroyed').reset();
renderer.spy('createView').reset(); renderer.spy('createView').reset();
renderer.spy('destroyView').reset(); renderer.spy('destroyView').reset();
renderer.spy('createRootHostView').reset(); renderer.spy('createRootHostView').reset();
@ -120,7 +120,7 @@ export function main() {
var rootView = var rootView =
internalView(<ViewRef>manager.createRootHostView(wrapPv(hostProtoView), null, null)); internalView(<ViewRef>manager.createRootHostView(wrapPv(hostProtoView), null, null));
expect(rootView.proto).toBe(hostProtoView); expect(rootView.proto).toBe(hostProtoView);
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(rootView); expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(rootView);
}); });
it('should hydrate the view', () => { it('should hydrate the view', () => {
@ -178,7 +178,7 @@ export function main() {
it('should destroy the render view', () => { it('should destroy the render view', () => {
manager.destroyRootHostView(wrapView(hostView)); manager.destroyRootHostView(wrapView(hostView));
expect(renderer.spy('destroyView')).toHaveBeenCalledWith(hostRenderViewRef); 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', () => { it('should not return the view to the pool', () => {
@ -223,7 +223,7 @@ export function main() {
internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef)); internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef));
expect(childView.proto).toBe(childProtoView); expect(childView.proto).toBe(childProtoView);
expect(childView).toBe(hostView.views[2]); expect(childView).toBe(hostView.views[2]);
expect(viewListener.spy('viewCreated')).not.toHaveBeenCalled(); expect(viewListener.spy('onViewCreated')).not.toHaveBeenCalled();
expect(renderer.spy('createView')).not.toHaveBeenCalled(); expect(renderer.spy('createView')).not.toHaveBeenCalled();
}); });
@ -264,7 +264,7 @@ export function main() {
internalView(manager.createEmbeddedViewInContainer(vcRef, 1, templateRef)); internalView(manager.createEmbeddedViewInContainer(vcRef, 1, templateRef));
expect(childView.proto).toBe(childProtoView); expect(childView.proto).toBe(childProtoView);
expect(childView).not.toBe(firstChildView); expect(childView).not.toBe(firstChildView);
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(childView); expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(childView);
expect(renderer.spy('createView')) expect(renderer.spy('createView'))
.toHaveBeenCalledWith(childProtoView.render, .toHaveBeenCalledWith(childProtoView.render,
childProtoView.mergeInfo.embeddedViewCount + 1); childProtoView.mergeInfo.embeddedViewCount + 1);
@ -309,7 +309,7 @@ export function main() {
internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef)); internalView(manager.createEmbeddedViewInContainer(vcRef, 0, templateRef));
expect(childView.proto).toBe(childProtoView); expect(childView.proto).toBe(childProtoView);
expect(childView).toBe(hostView.views[2]); expect(childView).toBe(hostView.views[2]);
expect(viewListener.spy('viewCreated')).not.toHaveBeenCalled(); expect(viewListener.spy('onViewCreated')).not.toHaveBeenCalled();
expect(renderer.spy('createView')).not.toHaveBeenCalled(); expect(renderer.spy('createView')).not.toHaveBeenCalled();
}); });
@ -329,7 +329,7 @@ export function main() {
<ViewRef>manager.createHostViewInContainer(vcRef, 0, wrapPv(newHostPv), null)); <ViewRef>manager.createHostViewInContainer(vcRef, 0, wrapPv(newHostPv), null));
expect(newHostView.proto).toBe(newHostPv); expect(newHostView.proto).toBe(newHostPv);
expect(newHostView).not.toBe(hostView.views[2]); expect(newHostView).not.toBe(hostView.views[2]);
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(newHostView); expect(viewListener.spy('onViewCreated')).toHaveBeenCalledWith(newHostView);
expect(renderer.spy('createView')) expect(renderer.spy('createView'))
.toHaveBeenCalledWith(newHostPv.render, newHostPv.mergeInfo.embeddedViewCount + 1); .toHaveBeenCalledWith(newHostPv.render, newHostPv.mergeInfo.embeddedViewCount + 1);
}); });