diff --git a/examples/horizon-nativescript-chat-app/.gitignore b/examples/horizon-nativescript-chat-app/.gitignore
new file mode 100644
index 000000000..f0f59f7a4
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/.gitignore
@@ -0,0 +1,8 @@
+node_modules
+hooks
+platforms
+.vscode
+
+*.js
+*.map
+*.log
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/README.md b/examples/horizon-nativescript-chat-app/README.md
new file mode 100644
index 000000000..90f620188
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/README.md
@@ -0,0 +1,29 @@
+This is an example of how to integrate [Horizon](http://horizon.io/) with a [NativeScript](https://www.nativescript.org/) app.
+
+### Prerequisites
+
+* Install Rethinkdb: https://rethinkdb.com/docs/install/
+* Install Horizon: `npm install -g horizon`
+
+
+## Server Setup
+
+### Create horizon server
+
+```
+hz init nschatApp
+cd nschatAPP
+hz serve --dev --allow-unauthenticated true --auto-create-collection true --auto-create-index true
+```
+
+##Start Android version
+```
+npm i
+tns run android
+```
+
+##Start iOS version
+```
+npm i
+tns run ios
+```
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/AndroidManifest.xml b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/AndroidManifest.xml
new file mode 100644
index 000000000..8d827dc8d
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/AndroidManifest.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/app.gradle b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/app.gradle
new file mode 100644
index 000000000..725fb59b1
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/app.gradle
@@ -0,0 +1,15 @@
+// Add your native dependencies here:
+
+// Uncomment to add recyclerview-v7 dependency
+//dependencies {
+// compile 'com.android.support:recyclerview-v7:+'
+//}
+
+android {
+ defaultConfig {
+ generatedDensities = []
+ }
+ aaptOptions {
+ additionalParameters "--no-version-vectors"
+ }
+}
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png
new file mode 100755
index 000000000..1034356e2
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png
new file mode 100755
index 000000000..ddfc17a71
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png
new file mode 100755
index 000000000..486e41091
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png
new file mode 100644
index 000000000..bd53be2ec
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-568h@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-568h@2x.png
new file mode 100755
index 000000000..d7f17fcd2
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-568h@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-667h@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-667h@2x.png
new file mode 100644
index 000000000..b88415405
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-667h@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-736h@3x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-736h@3x.png
new file mode 100644
index 000000000..faab4b631
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-736h@3x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png
new file mode 100644
index 000000000..d21bd292b
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png
new file mode 100644
index 000000000..5305bbdf2
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape.png
new file mode 100755
index 000000000..3365ba3cd
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png
new file mode 100755
index 000000000..a44945c1a
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png
new file mode 100644
index 000000000..e6dca6269
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait.png
new file mode 100755
index 000000000..1a5007962
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png
new file mode 100755
index 000000000..73d8b920f
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default.png
new file mode 100755
index 000000000..9f1f6ce3e
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default@2x.png
new file mode 100755
index 000000000..514fc5cde
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Default@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50.png
new file mode 100755
index 000000000..4a62478f9
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png
new file mode 100755
index 000000000..01ff7c16c
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small.png
new file mode 100755
index 000000000..9e13a222a
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small@2x.png
new file mode 100755
index 000000000..89dd84cd8
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Icon-Small@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Info.plist b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Info.plist
new file mode 100644
index 000000000..0a8e1eb1f
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/Info.plist
@@ -0,0 +1,66 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleDisplayName
+ ${PRODUCT_NAME}
+ CFBundleExecutable
+ ${EXECUTABLE_NAME}
+ CFBundleIconFile
+ icon.png
+ CFBundleIcons
+
+ CFBundlePrimaryIcon
+
+ CFBundleIconFiles
+
+ icon-40
+ icon-60
+ icon-72
+ icon-76
+ Icon-Small
+ Icon-Small-50
+
+ UIPrerenderedIcon
+
+
+
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ ${PRODUCT_NAME}
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIRequiresFullScreen
+
+ UIRequiredDeviceCapabilities
+
+ armv7
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/build.xcconfig b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/build.xcconfig
new file mode 100644
index 000000000..26e7a5841
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/build.xcconfig
@@ -0,0 +1,5 @@
+// You can add custom settings here
+// for example you can uncomment the following line to force distribution code signing
+// CODE_SIGN_IDENTITY = iPhone Distribution
+// ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+// ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Brand Assets;
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40.png
new file mode 100755
index 000000000..9b36ac4fe
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40@2x.png
new file mode 100755
index 000000000..8ce4b8899
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-40@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60.png
new file mode 100755
index 000000000..d2e951831
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60@2x.png
new file mode 100755
index 000000000..693f67f66
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-60@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72.png
new file mode 100755
index 000000000..556bdd688
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72@2x.png
new file mode 100755
index 000000000..4f69cb25b
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-72@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76.png
new file mode 100755
index 000000000..1c659c62a
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76@2x.png
new file mode 100755
index 000000000..bcc126d30
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon-76@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon.png
new file mode 100755
index 000000000..beea81999
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon@2x.png b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon@2x.png
new file mode 100755
index 000000000..c3dc7b035
Binary files /dev/null and b/examples/horizon-nativescript-chat-app/app/App_Resources/iOS/icon@2x.png differ
diff --git a/examples/horizon-nativescript-chat-app/app/app.css b/examples/horizon-nativescript-chat-app/app/app.css
new file mode 100644
index 000000000..15bb47ec7
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/app.css
@@ -0,0 +1,13 @@
+.title {
+ font-size: 30;
+ horizontal-align: center;
+ margin: 20;
+}
+
+.message {
+ font-size: 20;
+ color: #284848;
+ horizontal-align: center;
+ margin: 0 20;
+ text-align: center;
+}
diff --git a/examples/horizon-nativescript-chat-app/app/app.ts b/examples/horizon-nativescript-chat-app/app/app.ts
new file mode 100644
index 000000000..50660631d
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/app.ts
@@ -0,0 +1,13 @@
+import application = require("application");
+var moment = require("moment");
+
+require('nativescript-websockets');
+
+function fromNow(value:Date): any {
+ if(value){
+ return moment(value).fromNow();
+ }
+}
+
+application.resources['fromNow'] = fromNow;
+application.start({ moduleName: "main-page" });
diff --git a/examples/horizon-nativescript-chat-app/app/config.ts b/examples/horizon-nativescript-chat-app/app/config.ts
new file mode 100644
index 000000000..bbb93584f
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/config.ts
@@ -0,0 +1,5 @@
+let options = {
+ SERVER_URL:'192.168.56.1:8181' //Genymotion
+}
+
+export = options;
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/app/main-page.ts b/examples/horizon-nativescript-chat-app/app/main-page.ts
new file mode 100644
index 000000000..1dbe89233
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/main-page.ts
@@ -0,0 +1,10 @@
+import { EventData } from "data/observable";
+import { Page } from "ui/page";
+import { HorizonDemo } from "./main-view-model";
+
+// Event handler for Page "navigatingTo" event attached in main-page.xml
+export function navigatingTo(args: EventData) {
+ // Get the event sender
+ var page = args.object;
+ page.bindingContext = new HorizonDemo();
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/app/main-page.xml b/examples/horizon-nativescript-chat-app/app/main-page.xml
new file mode 100644
index 000000000..831d3dc46
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/main-page.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/horizon-nativescript-chat-app/app/main-view-model.ts b/examples/horizon-nativescript-chat-app/app/main-view-model.ts
new file mode 100644
index 000000000..e70aaad87
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/main-view-model.ts
@@ -0,0 +1,67 @@
+var Horizon = require('@horizon/client/dist/horizon-dev');
+import {Observable} from 'data/observable';
+import {ObservableArray} from 'data/observable-array';
+import frame = require("ui/frame");
+import {ListView} from 'ui/list-view';
+var config = require('./config');
+
+const SERVER_URL = config.SERVER_URL;
+
+export class HorizonDemo extends Observable {
+ public messages: ObservableArray;
+ public newMessage: string;
+ private horizon;
+ private chat;
+ private avatar_url = `http://api.adorable.io/avatars/50/${new Date().getMilliseconds()}.png`;
+
+ constructor() {
+ super();
+ this.messages = new ObservableArray();
+
+ this.horizon = new Horizon({ host: SERVER_URL });
+
+ this.horizon.onReady()
+ .subscribe(status => { console.log(status.type) })
+
+ this.horizon.onDisconnected()
+ .subscribe(status => { console.log(status.type) })
+
+ this.horizon.onSocketError()
+ .subscribe(status => { console.log(status.type) })
+
+ this.chat = this.horizon('messages');
+
+ this.getChats().subscribe((newMessage: any) => {
+ newMessage.map((val,index)=>{
+ this.messages.setItem(index,val);
+ });
+ this.messages.reverse();
+ });
+ }
+
+ private getChats() {
+ return this.chat
+ .order('timeStamp', 'descending')
+ .limit(10)
+ .watch();
+ }
+
+ public addMessage() {
+ this.chat
+ .store({
+ text: this.newMessage,
+ timeStamp: new Date(),
+ avatar: this.avatar_url,
+ }).subscribe((res) => {
+ console.log(`Adding new message:`);
+ let lv = frame.topmost().getViewById('list');
+ lv.scrollToIndex(this.messages.length - 1);
+ },
+ (error) => { console.log(error) });
+ this.set('newMessage', '');
+ }
+
+ private getStatus() {
+ return this.horizon.status();
+ }
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/app/package.json b/examples/horizon-nativescript-chat-app/app/package.json
new file mode 100644
index 000000000..a5683389d
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/app/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "tns-template-hello-world-ts",
+ "main": "app.js",
+ "version": "2.0.0",
+ "author": "Telerik ",
+ "description": "Nativescript hello-world-ts project template",
+ "license": "Apache-2.0",
+ "keywords": [
+ "telerik",
+ "mobile",
+ "nativescript",
+ "{N}",
+ "tns",
+ "appbuilder",
+ "template"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:NativeScript/template-hello-world-ts.git"
+ },
+ "bugs": {
+ "url": "https://github.com/NativeScript/template-hello-world-ts/issues"
+ },
+ "homepage": "https://github.com/NativeScript/template-hello-world-ts",
+ "android": {
+ "v8Flags": "--expose_gc"
+ },
+ "devDependencies": {
+ "nativescript-dev-typescript": "^0.3.0"
+ }
+}
diff --git a/examples/horizon-nativescript-chat-app/package.json b/examples/horizon-nativescript-chat-app/package.json
new file mode 100644
index 000000000..1f027d6c3
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/package.json
@@ -0,0 +1,30 @@
+{
+ "description": "NativeScript Application",
+ "license": "SEE LICENSE IN ",
+ "readme": "NativeScript Application",
+ "repository": "",
+ "nativescript": {
+ "id": "org.nativescript.nativescriptchatapp",
+ "tns-android": {
+ "version": "2.0.0"
+ },
+ "tns-ios": {
+ "version": "2.0.0"
+ }
+ },
+ "dependencies": {
+ "@horizon/client": "^1.0.1",
+ "moment": "^2.13.0",
+ "nativescript-websockets": "1.2.1",
+ "tns-core-modules": "2.0.1"
+ },
+ "devDependencies": {
+ "babel-traverse": "6.9.0",
+ "babel-types": "6.9.0",
+ "babylon": "6.8.0",
+ "filewalker": "0.1.2",
+ "lazy": "1.0.11",
+ "nativescript-dev-typescript": "^0.3.0",
+ "typescript": "^1.8.10"
+ }
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/references.d.ts b/examples/horizon-nativescript-chat-app/references.d.ts
new file mode 100644
index 000000000..b14f3837d
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/references.d.ts
@@ -0,0 +1 @@
+/// Needed for autocompletion and compilation.
\ No newline at end of file
diff --git a/examples/horizon-nativescript-chat-app/tsconfig.json b/examples/horizon-nativescript-chat-app/tsconfig.json
new file mode 100644
index 000000000..0ec588987
--- /dev/null
+++ b/examples/horizon-nativescript-chat-app/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "noEmitHelpers": true,
+ "noEmitOnError": true
+ },
+ "exclude": [
+ "node_modules",
+ "platforms"
+ ]
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/.gitignore b/examples/horizon-nativescript-ng2-chat-app/.gitignore
new file mode 100644
index 000000000..2ea506eb5
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/.gitignore
@@ -0,0 +1,7 @@
+node_modules
+hooks
+platforms
+.vscode
+
+*.js
+*.map
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/README.md b/examples/horizon-nativescript-ng2-chat-app/README.md
new file mode 100644
index 000000000..050285810
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/README.md
@@ -0,0 +1,31 @@
+This is an example of how to integrate [Horizon](http://horizon.io/) with a [NativeScript](https://www.nativescript.org/) + [Angular2](https://angular.io/) app.
+
+### Prerequisites
+
+* Install Rethinkdb: https://rethinkdb.com/docs/install/
+* Install Horizon: `npm install -g horizon`
+* Install TypeScript : `npm install -g typescript`
+
+
+## Server Setup
+
+
+##Create horizon server
+
+```
+hz init nschatApp
+cd nschatAPP
+hz serve --dev --allow-unauthenticated true --auto-create-collection true --auto-create-index true
+```
+
+##Start Android version
+```
+npm i
+tns run android
+```
+
+##Start IOS version
+```
+npm i
+tns run ios
+```
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/.npmignore b/examples/horizon-nativescript-ng2-chat-app/app/.npmignore
new file mode 100644
index 000000000..179affcf9
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/.npmignore
@@ -0,0 +1,13 @@
+node_modules
+built
+tags
+typings
+.baseDir.ts
+.tscache
+
+app/**/*.js
+app/**/*.map
+platforms
+lib
+
+*.tgz
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/AndroidManifest.xml b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/AndroidManifest.xml
new file mode 100644
index 000000000..8d827dc8d
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/AndroidManifest.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/app.gradle b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/app.gradle
new file mode 100644
index 000000000..725fb59b1
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/app.gradle
@@ -0,0 +1,15 @@
+// Add your native dependencies here:
+
+// Uncomment to add recyclerview-v7 dependency
+//dependencies {
+// compile 'com.android.support:recyclerview-v7:+'
+//}
+
+android {
+ defaultConfig {
+ generatedDensities = []
+ }
+ aaptOptions {
+ additionalParameters "--no-version-vectors"
+ }
+}
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png
new file mode 100755
index 000000000..1034356e2
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-hdpi/icon.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png
new file mode 100755
index 000000000..ddfc17a71
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-ldpi/icon.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png
new file mode 100755
index 000000000..486e41091
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-mdpi/icon.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png
new file mode 100644
index 000000000..bd53be2ec
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-568h@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-568h@2x.png
new file mode 100755
index 000000000..d7f17fcd2
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-568h@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-667h@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-667h@2x.png
new file mode 100644
index 000000000..b88415405
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-667h@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-736h@3x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-736h@3x.png
new file mode 100644
index 000000000..faab4b631
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-736h@3x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png
new file mode 100644
index 000000000..d21bd292b
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-568h@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png
new file mode 100644
index 000000000..5305bbdf2
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape-667h@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape.png
new file mode 100755
index 000000000..3365ba3cd
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png
new file mode 100755
index 000000000..a44945c1a
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png
new file mode 100644
index 000000000..e6dca6269
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Landscape@3x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait.png
new file mode 100755
index 000000000..1a5007962
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png
new file mode 100755
index 000000000..73d8b920f
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default-Portrait@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default.png
new file mode 100755
index 000000000..9f1f6ce3e
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default@2x.png
new file mode 100755
index 000000000..514fc5cde
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Default@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50.png
new file mode 100755
index 000000000..4a62478f9
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png
new file mode 100755
index 000000000..01ff7c16c
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small-50@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small.png
new file mode 100755
index 000000000..9e13a222a
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small@2x.png
new file mode 100755
index 000000000..89dd84cd8
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Icon-Small@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Info.plist b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Info.plist
new file mode 100644
index 000000000..0a8e1eb1f
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/Info.plist
@@ -0,0 +1,66 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleDisplayName
+ ${PRODUCT_NAME}
+ CFBundleExecutable
+ ${EXECUTABLE_NAME}
+ CFBundleIconFile
+ icon.png
+ CFBundleIcons
+
+ CFBundlePrimaryIcon
+
+ CFBundleIconFiles
+
+ icon-40
+ icon-60
+ icon-72
+ icon-76
+ Icon-Small
+ Icon-Small-50
+
+ UIPrerenderedIcon
+
+
+
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ ${PRODUCT_NAME}
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIRequiresFullScreen
+
+ UIRequiredDeviceCapabilities
+
+ armv7
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/build.xcconfig b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/build.xcconfig
new file mode 100644
index 000000000..26e7a5841
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/build.xcconfig
@@ -0,0 +1,5 @@
+// You can add custom settings here
+// for example you can uncomment the following line to force distribution code signing
+// CODE_SIGN_IDENTITY = iPhone Distribution
+// ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+// ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Brand Assets;
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40.png
new file mode 100755
index 000000000..9b36ac4fe
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40@2x.png
new file mode 100755
index 000000000..8ce4b8899
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-40@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60.png
new file mode 100755
index 000000000..d2e951831
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60@2x.png
new file mode 100755
index 000000000..693f67f66
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-60@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72.png
new file mode 100755
index 000000000..556bdd688
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72@2x.png
new file mode 100755
index 000000000..4f69cb25b
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-72@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76.png
new file mode 100755
index 000000000..1c659c62a
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76@2x.png
new file mode 100755
index 000000000..bcc126d30
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon-76@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon.png
new file mode 100755
index 000000000..beea81999
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon@2x.png b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon@2x.png
new file mode 100755
index 000000000..c3dc7b035
Binary files /dev/null and b/examples/horizon-nativescript-ng2-chat-app/app/App_Resources/iOS/icon@2x.png differ
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/LICENSE b/examples/horizon-nativescript-ng2-chat-app/app/LICENSE
new file mode 100644
index 000000000..a2ea2e632
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2015, Telerik AD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/app.component.ts b/examples/horizon-nativescript-ng2-chat-app/app/app.component.ts
new file mode 100644
index 000000000..526fe9e97
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/app.component.ts
@@ -0,0 +1,8 @@
+import {Component} from '@angular/core';
+import {ChatComponent} from './components/chat/chat.component';
+@Component({
+ selector: "my-app",
+ template: "",
+ directives: [ChatComponent]
+})
+export class AppComponent {}
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/app.css b/examples/horizon-nativescript-ng2-chat-app/app/app.css
new file mode 100644
index 000000000..4cb182a49
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/app.css
@@ -0,0 +1,6 @@
+.messages{
+ padding: 5
+}
+.messages Label{
+ padding-left:5
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.html b/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.html
new file mode 100644
index 000000000..b74d1acd3
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.ts b/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.ts
new file mode 100644
index 000000000..f8bdc42cf
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/components/chat/chat.component.ts
@@ -0,0 +1,44 @@
+import {Component, OnInit,PipeTransform,Pipe} from '@angular/core';
+import {HorizonService} from '../../services/horizon.service';
+import {Http} from '@angular/http';
+import * as moment from 'moment';
+import {FromNowPipe} from '../../pipes/fromnow.pipe';
+import {ListView} from 'ui/list-view'
+@Component({
+ selector: 'chat',
+ templateUrl: 'components/chat/chat.component.html',
+ providers: [HorizonService,ListView],
+ pipes: [FromNowPipe]
+})
+
+
+export class ChatComponent implements OnInit {
+ newMessage;
+ messages;
+ constructor(private hs: HorizonService, private http: Http,private listview:ListView) {
+ this.messages = [];
+ this.newMessage = '';
+ }
+
+ ngOnInit() {
+ this.hs.getChats()
+ .subscribe((newMessage) => {
+ this.messages = [...newMessage].reverse();
+ console.log('updating')
+ },
+ error => { console.log(error) })
+ }
+
+ addMessage(message) {
+ this.hs.addMessage(message)
+ .subscribe((res) => {
+ this.listview.scrollToIndex(this.messages.length - 1)
+ console.log(res);
+ console.log(`Adding new message:`);
+ console.log(this.newMessage);
+ },
+ error => { console.log(error) })
+ this.newMessage = '';
+
+ }
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/config.ts b/examples/horizon-nativescript-ng2-chat-app/app/config.ts
new file mode 100644
index 000000000..bbb93584f
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/config.ts
@@ -0,0 +1,5 @@
+let options = {
+ SERVER_URL:'192.168.56.1:8181' //Genymotion
+}
+
+export = options;
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/main.ts b/examples/horizon-nativescript-ng2-chat-app/app/main.ts
new file mode 100644
index 000000000..ef133d62b
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/main.ts
@@ -0,0 +1,7 @@
+// this import should be first in order to load some required settings (like globals and reflect-metadata)
+import {nativeScriptBootstrap} from "nativescript-angular/application";
+import {HTTP_PROVIDERS} from '@angular/http';
+require('nativescript-websockets'); // VERY IMPORTANT this comes BEFORE import of root component below!
+import {AppComponent} from "./app.component";
+
+nativeScriptBootstrap(AppComponent, [HTTP_PROVIDERS]);
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/package.json b/examples/horizon-nativescript-ng2-chat-app/app/package.json
new file mode 100644
index 000000000..290eb5aba
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/package.json
@@ -0,0 +1,32 @@
+{
+ "nativescript": {
+ "id": "org.nativescript.helloworldng"
+ },
+ "name": "tns-template-hello-world-ng",
+ "main": "main.js",
+ "version": "2.0.3",
+ "author": {
+ "name": "Telerik",
+ "email": "support@telerik.com"
+ },
+ "description": "Nativescript Angular Hello World template",
+ "license": "BSD",
+ "keywords": [
+ "telerik",
+ "mobile",
+ "angular",
+ "nativescript",
+ "{N}",
+ "tns",
+ "appbuilder",
+ "template"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/NativeScript/template-hello-world-ng.git"
+ },
+ "homepage": "https://github.com/NativeScript/template-hello-world-ng",
+ "android": {
+ "v8Flags": "--expose_gc"
+ }
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/pipes/fromnow.pipe.ts b/examples/horizon-nativescript-ng2-chat-app/app/pipes/fromnow.pipe.ts
new file mode 100644
index 000000000..fa2df75be
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/pipes/fromnow.pipe.ts
@@ -0,0 +1,14 @@
+import {PipeTransform,Pipe} from '@angular/core';
+import * as moment from 'moment';
+
+@Pipe({
+ name:'fromNow'
+})
+
+export class FromNowPipe implements PipeTransform{
+ transform(value:Date){
+ if(value){
+ return moment(value).fromNow();
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/app/services/horizon.service.ts b/examples/horizon-nativescript-ng2-chat-app/app/services/horizon.service.ts
new file mode 100644
index 000000000..743d44ac5
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/app/services/horizon.service.ts
@@ -0,0 +1,51 @@
+var Horizon = require('@horizon/client/dist/horizon-dev');
+import {Injectable} from '@angular/core';
+import {Observable} from 'rxjs/Observable';
+import config = require('../config');
+const SERVER_URL = config.SERVER_URL;
+
+@Injectable()
+export class HorizonService {
+ private horizon;
+ private chat;
+ private avatar_url = `http://api.adorable.io/avatars/50/${new Date().getMilliseconds()}.png`;
+ constructor() {
+ this.horizon = new Horizon({ host: SERVER_URL });
+
+ this.horizon.onReady()
+ .subscribe(status => { console.log(status.type) })
+
+ this.horizon.onDisconnected()
+ .subscribe(status => { console.log(status.type) })
+
+ this.horizon.onSocketError()
+ .subscribe(status => { console.log(status.type) })
+
+ this.chat = this.horizon('messages');
+ }
+
+ connect() {
+ return this.horizon.connect();
+ }
+
+ getChats() {
+
+ return this.chat
+ .order('timeStamp', 'descending')
+ .limit(10)
+ .watch()
+
+ }
+ addMessage(text) {
+ return this.chat
+ .store({
+ text: text,
+ timeStamp: new Date(),
+ avatar: this.avatar_url,
+ });
+ }
+ getStatus() {
+ return this.horizon.status();
+ }
+
+}
diff --git a/examples/horizon-nativescript-ng2-chat-app/package.json b/examples/horizon-nativescript-ng2-chat-app/package.json
new file mode 100644
index 000000000..3a6b809aa
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/package.json
@@ -0,0 +1,51 @@
+{
+ "description": "Native demo app using horizon.io",
+ "license": "MIT",
+ "readme": "NativeScript Application",
+ "repository": "https://github.com/triniwiz/horizon-nativescript-chat-app",
+ "nativescript": {
+ "id": "org.nativescript.horizonnativescriptchatapp",
+ "tns-android": {
+ "version": "2.0.0"
+ },
+ "tns-ios": {
+ "version": "2.0.0"
+ }
+ },
+ "dependencies": {
+ "@angular/common": "2.0.0-rc.1",
+ "@angular/compiler": "2.0.0-rc.1",
+ "@angular/core": "2.0.0-rc.1",
+ "@angular/http": "2.0.0-rc.1",
+ "@angular/platform-browser": "2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "2.0.0-rc.1",
+ "@angular/platform-server": "2.0.0-rc.1",
+ "@angular/router": "2.0.0-rc.1",
+ "@angular/router-deprecated": "2.0.0-rc.1",
+ "@horizon/client": "^1.0.1",
+ "moment": "^2.13.0",
+ "nativescript-angular": "0.1.1",
+ "nativescript-websockets": "1.2.1",
+ "rxjs": "5.0.0-beta.6",
+ "tns-core-modules": "^2.0.0"
+ },
+ "devDependencies": {
+ "babel-traverse": "6.9.0",
+ "babel-types": "6.9.0",
+ "babylon": "6.8.0",
+ "filewalker": "0.1.2",
+ "lazy": "1.0.11",
+ "nativescript-dev-typescript": "^0.3.2",
+ "typescript": "^1.8.10"
+ },
+ "author": {
+ "name": "Osei Fortune ",
+ "email": "fortune.osei@yahoo.com",
+ "url": "http://fitcom.co"
+ },
+ "contributors": [
+ {
+ "name": "Nathan Walker "
+ }
+ ]
+}
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/references.d.ts b/examples/horizon-nativescript-ng2-chat-app/references.d.ts
new file mode 100644
index 000000000..b14f3837d
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/references.d.ts
@@ -0,0 +1 @@
+/// Needed for autocompletion and compilation.
\ No newline at end of file
diff --git a/examples/horizon-nativescript-ng2-chat-app/tsconfig.json b/examples/horizon-nativescript-ng2-chat-app/tsconfig.json
new file mode 100644
index 000000000..ca2104605
--- /dev/null
+++ b/examples/horizon-nativescript-ng2-chat-app/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true
+ },
+ "exclude": [
+ "node_modules",
+ "platforms"
+ ]
+}
\ No newline at end of file