meteor-useraccounts / core

Meteor sign up and sign in templates' core functionalities
http://useraccounts.meteor.com/
MIT License
529 stars 279 forks source link

Don't hardly depend on iron:router - Flow Router Integration #308

Closed ghost closed 9 years ago

ghost commented 9 years ago

I'd like to use the useraccounts package with the flow-router. Right now it's not possible to get rid of iron:router when using the useraccounts package because of the hard dependency on it.

My suggested solutions to fix this are either:

  1. Make iron:router specific features optional. They are only available when the app uses iron:router. This can be achieved by making the dependency to iron:router weak and check the existence of Package['iron:router'] for the iron:router specific parts.
  2. Use polymorphism to support multiple routers. Create a common router interface object that will delegate the execution to the router that is included in the app. This would be iron:router, meteorhacks:flow-router or a "no router" implementation.
arunoda commented 9 years ago

Good job guys. I really like the no-route solution for user-accounts.

@rclai yes flow-router's idea is to decouple and use it with different layout engines. I think the idea is successful with since now we can use both Blaze and React with FlowRouter. That's why I like a router independent version.

splendido commented 9 years ago

@rclai I'm sorry you guys had to wait 100 comments before getting things moving on... I really hoped v2.0 was out much earlier with the routing stuff taken out of core, but I've been away for more than a month and I'm having very little spare time right now.

Hopefully things will get better also thanks to contributions from the community...

splendido commented 9 years ago

@arunoda I'm glad you like it!

splendido commented 9 years ago

I've just pushed a first version of flow-rounting! I had to change a bit of stuff also in core to handle a few things.., but I had no time to test anything :(

Please let me know in case you get a chance to play a little with the new packages and find some problem!

tjmonsi commented 9 years ago

@splendido Will try in a few, but how will it work with let's say, useraccounts:materialize?

tjmonsi commented 9 years ago

Hi @splendido

Had to use this with a simple project and here's what I got:

W20150806-01:19:59.757(-4)? (STDERR)          
W20150806-01:19:59.759(-4)? (STDERR) /home/dev/.meteor/packages/meteor-tool/.1.1.4.beln8f++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150806-01:19:59.760(-4)? (STDERR)                                            throw(ex);
W20150806-01:19:59.760(-4)? (STDERR)                                                  ^
W20150806-01:19:59.760(-4)? (STDERR) TypeError: Cannot set property 'defaultLayoutRegions' of undefined
W20150806-01:19:59.760(-4)? (STDERR)     at packages/underscore/underscore.js:848:1
W20150806-01:19:59.760(-4)? (STDERR)     at Array.forEach (native)
W20150806-01:19:59.761(-4)? (STDERR)     at _.each._.forEach (packages/underscore/underscore.js:105:1)
W20150806-01:19:59.761(-4)? (STDERR)     at Function._.extend (packages/underscore/underscore.js:845:1)
W20150806-01:19:59.761(-4)? (STDERR)     at Package (packages/useraccounts:flow-routing/lib/core.js:15:1)
W20150806-01:19:59.761(-4)? (STDERR)     at /home/dev/workspace/bellweather-project/.meteor/local/build/programs/server/packages/useraccounts_flow-routing.js:257:4
W20150806-01:19:59.761(-4)? (STDERR)     at /home/dev/workspace/bellweather-project/.meteor/local/build/programs/server/packages/useraccounts_flow-routing.js:264:3
W20150806-01:19:59.762(-4)? (STDERR)     at /home/dev/workspace/bellweather-project/.meteor/local/build/programs/server/boot.js:222:10
W20150806-01:19:59.762(-4)? (STDERR)     at Array.forEach (native)
W20150806-01:19:59.762(-4)? (STDERR)     at Function._.each._.forEach (/home/dev/.meteor/packages/meteor-tool/.1.1.4.beln8f++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8

and it still loads iron router dependencies because it tries to load useraccounts:core. It messes up with the already loaded FlowRouter.

tjmonsi commented 9 years ago

Here's what it is loading in my dependencies:

iron:controller            added, version 1.0.8
iron:core                  added, version 1.0.8
iron:dynamic-template      added, version 1.0.8
iron:layout                added, version 1.0.8
iron:location              added, version 1.0.9
iron:middleware-stack      added, version 1.0.9
iron:router                added, version 1.0.9
iron:url                   added, version 1.0.9
useraccounts:core          added, version 1.11.1
useraccounts:flow-routing  added, version 1.11.1

While I already have these:

// Using FlowRouter
    "kadira:flow-router@2.0.2",
    "kadira:blaze-layout@2.0.0",

I think I'll try forking useraccounts:core and useraccounts:materialize and maybe remove the dependencies on iron router, then just try to play with it (Might just plan on using FlowRouter as is to define the routes)

tjmonsi commented 9 years ago

Ok I got it working now,

Forked your useraccounts:core (just found out that the core dependencies on Iron Router was removed yesterday, used mine for now)

Then did this...

"useraccounts:materialize@1.10.0",
"useraccounts:flow-routing@1.11.1",

It is currently working... for now... will update in a few

splendido commented 9 years ago

Sorry, I should have mentioned I still haven't published the new changes. So, yes, to test the new packages you have to do it with local clones...

Then:

should be enough to go, provided you have local clones for useraccounts:core, and useraccounts:flow-routing (for useraccounts:materialize the latest published version should be just fine)

splendido commented 9 years ago

The useraccounts:flow-routing package is out! Thank you all for the great support :-)

...please report problems in separate issues from now.

splendido commented 9 years ago

...please try it out and in case you like it, star it both on atmosphere and github ;-)