kahmali/meteor-restivus

Export Router.

nishp1 opened this issue · 10 comments

I need to disable clientside router which can be done via Router.options.autoStart = false;, but need the Router exposed.

I just published an updated version (0.6.4) that adds a new configuration option to resolve this issue. So now you just need to set the useClientRouter option to false when configuring Restivus, like so:

Restivus.configure({
  useClientRouter: false
  // Any other config options you'd like to set
});

And that should take care of it for you. Since this now requires Restivus to configure things on both the client and the server, you have to be sure to call Restivus.configure from the client with this option. You can just configure everything once in a common file (one that is loaded on both the client and server), if that makes things easier.

I've updated the docs to reflect these changes. Let me know if you have any other issues with the latest update. Thanks for putting in this request!

Thanks for quick turn around.

Looks like Restivus isn't exposed on the client, getting Uncaught TypeError: Cannot read property 'configure' of undefined error. Is there anything I need to do on my end to make it accessible?

Hmmm. I tested locally and it worked for me. Let me check it using the published package. In the meantime, I'll reopen the issue. Sorry about that. That's what I get for being too lazy to write an automated test for it.

No worries, happens to the best of us. Meanwhile, adding iron:router as a direct dependency lets me use Router directly.

This is extremely confusing. When I test locally, it works. If you look in package.js you'll see that restivus.coffee is being added on both the client and server (that's the default when neither is specified). That should allow you to call any methods defined in that file from both the client and the server (Restivus.configure is defined there). When I test locally, if I change it so that restivus.coffee is added only on the server, I get the same error we're getting on the published version, as expected, since the file is explicitly not being made available. So I'm getting two different results from the exact same package depending on whether it's local or published (which shouldn't be the case as far as I know), and I have no way to test a new published version without publishing to everyone. Maybe there's something I can do with semver to make people aware of that or make it so they have to explicitly request a package version in order to install or update to that version. Just thinking out loud in case anyone has any suggestions.

I was hoping to avoid you having to create the direct dependency on iron:router. I know it's not everyone's preferred router, and I intend to move away from it to an independent server-side router that plays nicely alongside others (like arunoda's Picker) as soon as I have the time. iron:router is overkill for this project. Glad you were at least able to find a usable workaround for now. Sorry about the hassle.

dandv commented

I have no way to test a new published version without publishing to everyone

You can create a -dummy copy of the package, publish, test, then run meteor admin set-unmigrated nimble:restivus-dummy, so it won't appear in Atmosphere searches.

Thanks @dandv! That's just what I needed to test this. That should help me push this along.

Def. weird...window does have Restivus exposed but as undefined.

#38 should fix this, I bet!

This is resolved by #46 (which removes Iron Router), and will be included in the next major update, v0.7.0. If you'd like early access, you can clone the latest from the 0.7.0 branch, and use it as a local package. Of course, that branch is a work in progress, so there could be some unexpected behavior. Thanks again for reporting this issue!