× {{alert.msg}} Never ask again
Receive New Tutorials
GET IT FREE

Q&A with Creator of Angular-Meteor, Uri Goldshtein

– {{showDate(postTime)}}

The post is based on the Codementor Office Hours hosted by Uri Goldshtein, who created the Angular Meteor library. Uri talks about how Blaze and Angular-Meteor compare, what databases Meteor supports, would Meteor apps hang, and more.

See Part 1 of the post here.


Blaze vs. Angular-Meteor

If you’re starting a new app and you have a team where everyone already knows Angular, then I would definitely try Meteor. Blaze is actually a good framework. Even though I’m an Angular developer and I wrote Angular-Meteor, I would urge people just to try Blaze just to get the feeling of it. I think they’ve done a lot of smart stuff there with Angular 2.0 ,which they’re going to introduce.

If you are a front-end developer and you’re searching for a back-end framework, you should definitely try Meteor.

If you already have an existing application: We worked on how to make it possible so it depends on how strong you have your service item. If you have existing code and libraries that you’ve done, I would definitely try Angular-Meteor with Meteor.

I see a lot of Rails developers who understand there’s something new, but they used to work with Rails and the framework gives them a really good ecosystem. So, Rails developers looking to move into Node but haven’t done so because of the lack of support and the lack of a framework that gives them control should give Meteor a try as well.

Does Meteor only work with Mongo DB?

Meteor the thing itself supports Mongo DB and Redis because Mongo DB was the best choice and the most popular one to start with. But it’s important to understand that Meteor is more of an architecture and a platform than a specific solution that works on one database, so you can actually do everything you want with it.

I think in terms of roadmap, the next thing Meteor is going to support is an SQL database, and my guess is probably postgres because there’s a lot of postgres developers who want that support.

Meteor is building a way for the architecture to work like a light query tier on top of a postgres will handle watching over postgres. This shouldn’t be hard because postgres is a great database and it’s very easy to work on top of it to get these changes. Meteor will likely build some kind of an API replica on the client side (and I think there’s probably existing solutions for that already) and then just sync it with the DDP open-source protocols. I think some people from the community are already working on this, but Meteor itself is going to support this in the future. However, at the moment, the best database to use with Meteor is indeed Mongo DB.

Will a Meteor App Hang

If it has too many cursors listening for the changes?

It depends on many different factors, such as if you have problems on the server-side or the client-side. I’ll talk about the client side because I wrote Angular-Meteor on that side.

The thing that costs the most is watching over Angular changes. It’s not about the amount of Angular arrays that you have, it’s about their size and how deep they are because Angular watch is pretty expensive. The longer and deeper your Angular arrays are, the less performant your app is going to be.

The easiest solution is to just not watch the Angular arrays. The second solution is to can paginate them, and you can see how to do that in this tutorial. A lot of people say that AngularJS is slow, and this is a very big statement. I think people are experiencing performance problems because they clutter the client-side with tons of code and data, but when you have a very simple server-side code, then it’s very easy for you to go with pagination. You can live with 30 objects on the client side and not 3000 (usually there’s no reason for you to have 3000 objects on the client side), and Angular can handle 30 objects without a problem. You shouldn’t even get to that point where you call that flag, even if it is always there for you to handle.

Projects done with Angular-Meteor

Angular-Meteor actually didn’t start out as an Angular-Meteor project—we just started this thing less than a year ago. Angular-Meteor was built on top of a project, as we first started out working on a project for hospitals.

It’s a system for scheduling interviews with doctors and it works across the web and mobile. We initially built the site with Rails and the app as a native iOS app, but we just migrated everything for Meteor. Since we thought we had a lot of great code done with Angular, we decided to try to work with them together, and this is how Angular-Meteor happened.

We have like three other projects, though I was contacted by many dev shops and enterprise companies  that work now primarily with Angular-Meteor and some of them actually work with famo.us & Angular-Meteor, some work with more standard solutions, like Angular-Meteor & Bootstrap or Ionic. I get a lot of emails every day from people working with Angular-Meteor, so I’m definitely thinking of making a page to showcase projects done with Angular-Meteor though.

The Meteor Object

I also want to talk a bit more about how Meteor objects work.

angular.module("socially").controller("PartyDetailsCtrl", ['$scope', '$stateParams', '$meteor',
	function($scope, $stateParams, $meteor) {
		$scope.party = $meteor.object(Parties, $stateParams.partyId);
}]);

We can take an object by ID, as you can see from the code above,  you can just call meteor.object, and again it’s an object of the parties but you just send an ID. From that point on, you can watch over that object and just change it on the fly.

However, like with the collection, you can send a flag so it would update explicitly. So, if you have a classic form with a save-intensive button, you can just send a flag:

$scope.save = function() {
	$scope.party.save();
};

$scope.reset = function() {
	$scope.party. reset();
};

Again, you’re not watching over the Angular changes, you’re just watching the Meteor changes and then you can explicitly call save. $scope.reset just resets the client-side party from the server, and it will just reset your form.

Meteor Methods

Method is another important concept in Meteor, and it is another part of the DDP protocol. You can call methods that can run both on the client and on the server. This means the logic will run on the client and everything will update instantly.

However, let’s say if you don’t have permissions to run it on both the client and on the server. When your method gets to the server and tries to do the same action, the action will be cancelled. Then it will revert back the changes if there were any. This is what you can call latency conversation, which is a really strong and powerful concept.

So to call Meteor functions like that, the only thing you need to do is use meteor.call. If you’re interested in learning more, I’d suggest checking out this tutorial.

When AngularJS developers started working with these methods, they’ll realize the client-side is not the best place to put all the logic. Like it’s the first time people are saying, “By default we do everything on the client side, but then you can feel why sometimes it is better if some stuff is on the server side and not on the client side.” I think it’s a very powerful concept for Angular developers to work with.

We also taken the Meteor Methods concept and built Angular-Server on top of that. now, instead of calling Meteor.call, you can actuallydefine an Angular service on your server and all it directly like any other Angular service. no need to define end-points and boilerplate code.

Meteor-Include

Another important thing is the Meteor-include directive.

<meteor-include
	src="">
</meteor-include>

Blaze (Meteor’s front-end portion) has a lot of bigger templates in the community. You can actually use an Angular directive that codes meteor-include in the source, where you just have to specify the name of the template, and you’re good to go. 


About Uri Goldshtein

Uri is the creator of the Angular-Meteor package, which makes the integration between AngularJS and Meteor as seamless as possible. Uri travels around the world building stuff and consulting to various companies. He started with Assembler, C++ & C#, and WPF before taking on the web a few years ago. Since then, he’s regularly spoken and lectured about AngularJS until he moved on to develop the library, Angular-Meteor.



Author
Urigo
Urigo
angular-meteor creator
https://github.com/urigo
Hire the Author

Questions about this tutorial?  Get Live 1:1 help from Meteor experts!
Matthew Knippen
Matthew Knippen
5.0
iOS developer with 50+ Apps. Founded 3 companies.
Specialties: • iPhone/iPad/iOS Development • Product Management & Development • Lean Startup • Entrepreneurship Would you like to see the...
Hire this Expert
Foysal
Foysal
5.0
javascript enthusiast with a taste for all new web technologies.
I have been programming on various web and cross platform stacks for 5 years. I love making things and helping people build things. If you need...
Hire this Expert

Or Become a Codementor!

Live 1:1 help from expert developers

Codementor is your live 1:1 expert mentor helping you in real time.

comments powered by Disqus
Codementor is your live 1:1 expert helping you in real time