Is Meteor Dynamics Coming Back?

It seems that Meteor Dynamics is a long forgotten thing. People spoke about it in 2013 but it has since been overshadowed by “broader JS community things” like React and GraphQL. Granted, I only got into Meteor in late 2015, but that was the inflection point.

No one speaks about write fences and invalidation crossbars any more. Heck, I can’t even remember how those things work. But it seems that Meteor Dynamics is being quietly led to the deprecation gallows, with no mention of Meteor.EnvironmentVariable on docs.meteor.com. I look forward to the future days when people start seeing Meteor Dynamics as retro.


I’ve recently experienced the need to have a little dynamic scoping in the style of Blaze’s Template.instance() (just tied the the Meteor Method invocation).

To that end I wrote a package convexset:fiber-scope that (by “taking reference from”/ripping off Meteor Dynamics) would allow code in Meteor methods (however deep in the call stack) to, with nice clean syntax, share a common Ted Steven-sian “big truck” object which they might manipulate in common (even in setTimeout's, setInterval's and defer's; and promises which Meteor’s polyfilled promise package enables with no further work).

In particular with Meteor methods…

Meteor.methods({
  "my-method": function(id) {
    this.unblock();  // enables yielding between calls from the same connection
    FiberScope.current.x = Math.random();
    FiberScope.current.y = Math.random();
    display(id);
    Meteor._sleepForMs(1000);  // causes a yield (other code can run during this pause)
    display(id);
  }
});

function display(id) {
  console.log(`[${id}] x=${FiberScope.current.x}, y=${FiberScope.current.y}`)
}

Invoking the above (unblocked) method twice in rapid succession like so

Meteor.call("my-method", 'one');
Meteor.call("my-method", 'two');

would predictably generate something like:

[one] x=0.23411111, y=0.42311111
[two] x=0.34522222, y=0.59422222
[one] x=0.23411111, y=0.42311111
[two] x=0.34522222, y=0.59422222

on the server console.

And the same works for code specified in timers or promises… or when one is doing recursion. Good old FiberScope.current would be there each step of the way, like a band of paid Sherpas following some rich guy who wants to climb Everest.


I would mention another place (package) where I found Meteor Dynamics to enable really nice clean syntax, but I realize that I have really crappy documentation. (It’s a package for providing flexible “mutual exclusion locking” functionality for Meteor called convexset:locker.)

But anyway… rambling aside, I find it a pity that the beauty of Meteor Dynamics is not being “developed upon”.

3 Likes