Meteor Mentor Session #4

What’s this all about? Some guy(Christian J) started looking for a Mentor in the Meteor forums. At first it seemed like no one wants to do…

Meteor Mentor Session #4

What’s this all about? Some guy(Christian J) started looking for a Mentor in the Meteor forums. At first it seemed like no one wants to do this for free, but after a few hours all whole bunch of devs wanted to join, so now we have a real community going on. We hold weekly meetups where we discuss some questions or even review some code. If your interested in this efforts feel free to post in the forum topic.

A short summary of this weeks topics

We started with some topics we discussed in slack.

Offline apps

Serkan introduced some basics about Offline apps, more precise offline modes for online apps. So when for example having an application which makes sense, even when not connected to the Internet, there are different packages to deliver offline functionality to your meteor app. For offline collections there is a package called grounddb. For static assets you can use appcache. Something new but worth a look and most likely evolving in the near future Service workers [1,2](Keyword: Offline-first).

Device Access

I thought about rebuilding a cross-platform alternative for bluegraph in Meteor, so we talked about things like electron, cordova and react-native. But also native browser support in chrome and hopefully somewhere else too in the future. Serkan also posted a link to Deco a shiny new tool for react native - which is absolutely worth the hype.

Meteor 1.3 npm imports

We talked about how “import” will affect the future of Meteor. The consent was something like. It’s still in transition state, so we’ll face some require problems because different packages can require different react versions. When everything is ready (in a few months) it will be awesome because we have more fine granular control over what to import where. So we can cherrypick stuff from all the packages out there.

tunnel via proxy server failed

ric0 deployed on Bluemix and got the error: WebSocket connection to ‘ws://foobar.com/rtc’ failed: Establishing a tunnel via proxy server failed. Usually Meteor should fallback tolong polling, but sometimes this doesn’t work. There are ways to disable websockets in Meteor, so ric0 should try if it works with disabled websockets, but also figure out why the problem occurred in the first place and report back.

Code questions

Handling friend request

Christian J is working on a chat and asked if transactions would be a good way to handle friend requests. It’s probably possible but overhead for this use-case. An intelligent database schema would do the trick.

Error prone development

Someone else asked if he could simply do

Collection.find({prop: this.userId})

without checking for undefined. You can, but you shouldn’t. It’s really bad practice. Without checking for undefined you always fire the request - even if no user is logged in. With huge databases or miss-configured databases (for example without indexing) this can lead to performance problems.

Should i return [] or this.ready()? Yes you should.

Collection holds more items than I expected on client side

That’s a common Problem. With mainly two reasons:

  1. When working with Meteor.users Database you always have yourself in the collection. This has the effect when for example publishing all users which aren’t verified and you list all users you will have yourself in that collection (even if you are verified).
  2. Multiple Publish/Subscribe will always merge due to merge-box! Even if you have template level subscriptions. As soon as having two Template level subscriptions rendered the same time - the subscriptions will merge.

As there are two reasons, there are three solutions:

  1. Simply use find({conditions}) on the client.
  2. Publish to different collections [1]
  3. Use some package workarounds (which won’t do any other magic) [1, 2]

Can I only publish collections?

No, you can publish anything [1, 2].

How to animate reactive data changes

There are a lot of packages out there [example 1]. Simply look on atmosphere.

Expire date

Last time we talked about data we want to be removed after time. For example to manage a huge chatlog - what do do when we just want to dump data when it’s older than … 3 days? Rob had a follow up link resource on this [1].

Lukas Strassel

Read more posts by this author.

Subscribe to Meteor University

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!