Multiple apps and working routes

305 views
Skip to first unread message

futur...@gmail.com

unread,
Feb 1, 2012, 10:43:11 PM2/1/12
to Sammy.js
Hi guys

I have two apps:

var app1 = $.sammy("#main-people",function(){
this.get("#/",function(context){console.log('index');});
this.get("#/birthdays",function(context){console.log('time to
load birthdays file');});
});

app.run('#/');

and later on I include other file

var app2 = $.sammy("#main-birthdays",function(){
this.get("#/week",function(context){console.log('load week
birthdays');});
this.get("#/month",function(context){console.log('load month
birthdays');});
});

app.run('#/week');


When I try to go #/week I get a 404 Not Found error, looks like sammy
search for the route only in app1 and leave app2 untouched, how can I
fix that? To make sammy stop looking the route exclusively in app1

Thank you

Daniel D.

unread,
Feb 5, 2012, 3:22:27 PM2/5/12
to sam...@googlegroups.com

Having separate apps does not require needing several Sammy.js instances.

Instead, suggest using one Sammy set up that 'publishes' the new route through PubSub and have the apps subscribe to it.

I could envision app name as first element in the routes,with the rest being dynamic (from 'splat') just published to all listeners. App that listens on channel labeled 'appname' and get deeper routing details as args.

This way (with pub sub) you will not feel compelled to use several dammies as you do not attach callbacks to routes directly

--
You received this message because you are subscribed to the Google Groups "Sammy.js" group.
To post to this group, send email to sam...@googlegroups.com.
To unsubscribe from this group, send email to sammyjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sammyjs?hl=en.

Richard Bucker

unread,
Apr 23, 2013, 11:29:24 AM4/23/13
to sam...@googlegroups.com
This explanation is confusing. Implementing a pubsub for each of the minor applications still results in the 404 as the get() is propagated to all of the apps. And one cannot swap() a control without an app; Can you GIST an example?
Reply all
Reply to author
Forward
0 new messages