Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding angular2-chat-app example #436

Closed
wants to merge 9 commits into from

Conversation

zubair-io
Copy link
Contributor

@zubair-io zubair-io commented May 19, 2016

Sorry for having to create a new pull request for this, my fork some how got disconnected and changes where not showing up.
The changes are:
Updated to angular 2.0.0-rc.1
Removing typings
Moving Horizon to a service


This change is Reviewable

@jonathan-casarrubias
Copy link

jonathan-casarrubias commented May 19, 2016

How to use the Horizon client without importing it within the index.html, in NativeScript we do not have an index.html so, I tried to import but not being able yet... any idea?

@marshall007
Copy link
Contributor

@jonathan-casarrubias are you using TypeScript? I think you should be able to do:

import * as Horizon from '@horizon/client'; 

@zubair-io
Copy link
Contributor Author

Also add "@horizon/client": "1.0.1" to the package.json

@jonathan-casarrubias
Copy link

jonathan-casarrubias commented May 20, 2016

Yeah I already tried that, I also created a simple definition and added it to the references.d.ts.

But when I try to compile I get the following error

`app/app.component.ts(2,21): error TS2307: Cannot find module '@horizon/client'.``

so the steps

1.- Created a NativeScript 2 App with Angular2 and TypeScript
2.- Created the definition and added it to the definitions
3.- installed @horizon/client 1.0.1
4.- Imported it from the app component

import {Component} from "@angular/core";
import * as Horizon from '@horizon/client'; 

@Component({
    selector: "my-app",
    template: `
<StackLayout>
    <Label text="Hello Horizon" class="title"></Label>
</StackLayout>
`,
})
export class AppComponent {}

When I visit the @horizon/client folder within the node_modules path, I see there is a dist, lib, package.json and README, but no index at all, so I found the files section within the package.json that actually points to dist and lib, but it does not work when trying to import it.

I also tried, to import @horizon/client/dist and @horizon/client/lib but still getting the same error.

If I use other 3rd party library like moment I can actually import it by using import * as moment from 'moment' so I can assume it is something specific with this horizon client library.

It is sad because I'm writing a blog post and project for this week about Horizon and NativeScript but this simple issue have me blocked.

I will keep playing with it to see if I can get to make it work, thanks in advanced for any help

Cheers,
Jon

@zubair-io
Copy link
Contributor Author

@jonathan-casarrubias Here are some examples of nativescript running with Horizon https://discuss.horizon.io/t/nativescript-starters-demos/152

@jonathan-casarrubias
Copy link

jonathan-casarrubias commented May 20, 2016

omg I was so god d*** close, I was trying var Horizon = require("@horizon/client/lib"); when you posted the answer, because in there I see the index.js, which by the way does not work.

Now pointing to "@horizon/client/dist/horizon" does compile, thanks a lot @helixten it would be super awesome to have this in the documentation.. I can help if needed.. Also I know TS comes in the next major release, so maybe is not even needed..

Cheers
Jon

@poznyakovskiy
Copy link
Contributor

The example is not working correctly. There's a bug in chat.component.ts, line 82: should be
.sendChat(text)

@zubair-io
Copy link
Contributor Author

Thanks @poznyakovskiy fixed

<html>

<head>
<title>Angular 2 QuickStart</title>
Copy link

@marcusreese marcusreese Jun 3, 2016

Choose a reason for hiding this comment

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

Might want to change the title so it's no longer 'Angular 2 QuickStart'. And add <!doctype html> to the top?

@deadcee
Copy link

deadcee commented Jun 20, 2016

@zubair-io Is it ok for me to help with anything on this?

@deadcee
Copy link

deadcee commented Jun 20, 2016

I have looked through this and it all appears to work perfectly apart from the last change suggested by @marcusreese so should be merged in my opinion.

@shantanubhadoria
Copy link

I can verify that this works on my local horizon setup. However I have to ask something possibly unrelated. Borrowing from the way it works on Meteor project is it possible to transpile, aggregate, minify and possibly uglify all the .ts on server side and keep the individual files in a folder not directly accessible by the client like imports/ ?
Thanks

@deontologician
Copy link
Contributor

@shantanubhadoria This is why hz serve only serves files in the dist/ directory. You can put your source files wherever you'd like and horizon won't serve them

@shantanubhadoria
Copy link

@deontologician Thanks for answering. How would I go about transpiling and aggregating .ts on the server side instead of loading individual components seperately on client with imports?
Thanks

@zubair-io
Copy link
Contributor Author

@shantanubhadoria I think you are looking for a bundler. Try adding webpack or systemjs-bundler

@somombo somombo mentioned this pull request Mar 8, 2017
@zubair-io zubair-io closed this Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants