Callback after the DOM was updated in Meteor.js

A hacky way to do it is: foo.html <template name=”mytemplate”> <div id=”my-magic-div”> .. stuff goes here .. {{add_my_special_behavior}} </div> </template> foo.js Template.mytemplate.add_my_special_behavior = function () { Meteor.defer(function () { // find #my-magic-div in the DOM // do stuff to it }); // return nothing }; The function will get called whenever the template is rendered … Read more

Uncaught TypeError: fs.readFileSync is not a function

The following webpack.config.js is working for me. It incorporates @also’s good idea for the brfs matcher: var webpack = require(‘webpack’) var path = require(‘path’) module.exports = { entry: ‘./app.js’, output: { path: __dirname, filename: ‘bundle.js’ }, resolve: { extensions: [”, ‘.js’], alias: { webworkify: ‘webworkify-webpack’, ‘mapbox-gl’: path.resolve(‘./node_modules/mapbox-gl/dist/mapbox-gl.js’) } }, module: { loaders: [ { test: … Read more

Apollo / GraphQl – Type must be Input type

From the spec: Fields may accept arguments to configure their behavior. These inputs are often scalars or enums, but they sometimes need to represent more complex values. A GraphQL Input Object defines a set of input fields; the input fields are either scalars, enums, or other input objects. This allows arguments to accept arbitrarily complex … Read more

How to get the user IP address in Meteor server?

1 – Without a http request, in the functions you should be able to get the clientIP with: clientIP = this.connection.clientAddress; //EX: you declare a submitForm function with Meteor.methods and //you call it from the client with Meteor.call(). //In submitForm function you will have access to the client address as above 2 – With a … Read more

How can I deploy node modules in a Meteor app on meteor.com?

As of Meteor 6.0, now we need to use Npm.require() instead. Additionally, we need to declare the module as global variables, since Meteor now has file-level scope. var path = Npm.require(‘path’); var fs = Npm.require(‘fs’); var base = path.resolve(‘.’); var isBundle = fs.existsSync(base + ‘/bundle’); var modulePath = base + (isBundle ? ‘/bundle/static’ : ‘/public’) … Read more

Meteor’s subscription and sync are slow

Meteor is pushing the entire dataset to your client. You can turn off autopublish by removing the autopublish package: meteor remove autopublish Then create specific a specific subscription for your client. When you subscribe you can pass a session variable as an argument, so on the client you do something like: sub = new Meteor.autosubscribe(function(){ … Read more