How to Start Application with Multiple Routers? - backbone.js

How should one load/start an application that has multiple routers? Should one simply load and initialize all routers in the "app.js" file? Thanks.

There shouldn't be a problem using multiple routers as long as you do not define a default or catch all route in more than one. Then you won't know what's going on.
In any case, just start up each one in sequence. They won't do anything until you navigate.

Related

Apache camel multiple dynamic route for single file

I have a dynamic route which reads and process a file and there could be multiple files. Each route is processing single file at a time. When request comes for different files at the same time there is no issue, as it creates unique URI based on file name. I also need to support parallel request for same file.
I am getting below exception for parallel request.
Failed to start route MyFileProcessorDynamicRoute because of Multiple consumers for the same endpoint is not allowed.
Is there a way where i can create chaining of route at runtime?
Thanks in advance.
As per your context I am getting to know, you have to use same file(having same name) to be used in different route at same time.
You can achieve by setting flag kind of thing(sequence order in which route has to run) in route were you need to process the same name file. By doing this you cannot start second route without completing first route.
This might tricky but achievable.
Thanks.

how to render multiple apps on single react page?

this image shows multiple apps that should run when I click on them individually.Like: if i click Filter then it should run Filter.js .
You should try react-router: https://github.com/ReactTraining/react-router
If I well understood, you're trying to split your app into sections and react-routing is great to do so. You also get path/link matching to your route as a bonus.
It comes with a nice tutorial https://github.com/reactjs/react-router-tutorial which shouldn't take long to go through. For your case, you should need just the first 3 steps.
Good luck.

How do I add an admin dashboard feature to my PSK app? And why can't I reach my admin.html page?

As soon as I unzipped and configured the PSK, I tried to add an admin.html page next to index.html from where I'd like to manage my application. However, when I try to reach it via localhost:3000/admin, I get redirected to localhost:3000/admin#!/admin where the original application, the one in index.html shows up, I think because of routing.
I tried removing the hashbang option from page.js, tried changing the / route to /home, all to no avail. The admin.html page doesn't want to show up.
How does one do that? Maybe I need to create another application all together and host it on /admin?
P.S. I am not asking about the security of the approach here. If you want to know anyway, I will try to manage security with firebase (still have to look into it). Thanks.
First, in order to get to admin.html, you need to use ".html" in your URL. So try using localhost:3000/admin.html.
Second, assuming you've made no changes but to duplicate the index.html and rename it admin.html, this will still trigger the routing. You'll need to either create new routing contexts to routing.js in order to control this page, which is a little awkward being it's essentially controlling two separate SPAs, or remove routing.js from your Vulcanized elements.html file so that it can be included only on the main app (index.html). The second option also opens the possibility of having multiple routing.js files so for example your admin.html could essentially become it's own SPA controlled by routing.admin.js.
Good luck!

Using 2 views and sharing data in AngularJS

Im trying to share data between 2 views. I need to use the 2 views at the same time on two different machines. One is controlling the other(ex: a counter) 1st view has next(+1) and the other just displays the result. I want the data to synchronized/binded. I do not want to have to refresh the 2nd page or to have to pull data with a timer or otherwise.
My idea was to use ng-view and routeProvider, I know that when the view changes the scope is cleared so I tried to use a parent controller/scope, the data is shared but I have to refresh the page on my 2nd view. I tried a service, same thing. I tried to $watch the result of the service but on the second controller/view no event is picked up so the view doesn't update.
what is the way to go? I was thinking about broadcasting or emit a custom event and trying to catch it, will that work? Am I just not binding to the service correctly? Would ui-router work better? I feel there should be an easy way to do this.... Im not seeing it! Please help if you can.
One of the simplest (in my opinion) implementations of client-client communication is using WebSockets. While that does have compatibility limitations (some browsers), that can easily be overcome by using a library like socket.io. Also, it's easy to write an Angular wrapper/service over socket.io that can be shared across components of your app, or even different modules.
It's also pretty simple to write a Node backend with socket.io
This might be a good read.
I would suggest you to focus on pushing stream rather than sharing it. Some how you need to push stream to second view which is changes in first view.
You may want to check this
Is there some way to PUSH data from web server to browser?

Purpose of Backbone's Router?

What is the purpose of Backbone's Router? Can't we do the same thing without it? With a router, a click on a link would change the URL of a page and the last bits of the URL would trigger a function. Why not just assign a click event on this link and trigger a function there?
I don't use backbone specifically, (rather, I use iron-router for my project) but it's purpose is to route URLs to pages. Consider the following: you have 50 links scattered across your website's source all pointing to /awesomePlace (which serves awesomePlace.html). You've decided awesomePlace isn't so awesome anymore and have declared that there is a moreAwesomePlace.html. You could go in and change each of those 50 links to /moreAwesomePlace or you could change the route once. The router could then serve up moreAwesomePlace.html whenever anybody visits /awesomePlace.
That's just one example. I personally haven't spent too much time with routers yet but I'm sure somebody can give some better examples than I have. Hopefully this helps explain things a bit though.
Yes, we can implement same functionalities without router, router is just an helper utility, just like JQuery for DOM manipulations. Reason behind using router all about scalability and flexibility. If you follow "on click do some thing", it does't scale. In a single page application every click might have multiple handlers. One click on item might demand changes to multiple widgets. with routers you can add/remove hooks for the same click. And in future if you want to change the implementation of Router or hooks, you are free to do that, only thing that you need to make sure is contract btw these two remain same.

Resources