Merge pull request #762 from NativeScript/add-and-removeEventListener-fixes

Add and remove event listener fixes
This commit is contained in:
Vladimir Enchev
2015-09-18 13:54:25 +03:00
2 changed files with 11 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>
<TypeScriptToolsVersion>1.6</TypeScriptToolsVersion>
<ProjectGuid>{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
@@ -1977,7 +1977,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -53,7 +53,12 @@ export class Observable implements definition.Observable {
}
public addEventListener(eventNames: string, callback: (data: definition.EventData) => void, thisArg?: any) {
if (!types.isString(eventNames)) {
throw new TypeError("Events name(s) must be string.");
}
types.verifyCallback(callback);
var events: Array<string> = eventNames.split(",");
for (var i = 0, l = events.length; i < l; i++) {
@@ -68,6 +73,10 @@ export class Observable implements definition.Observable {
}
public removeEventListener(eventNames: string, callback?: any, thisArg?: any) {
if (!types.isString(eventNames)) {
throw new TypeError("Events name(s) must be string.");
}
var events: Array<string> = eventNames.split(",");
for (var i = 0, l = events.length; i < l; i++) {