0

I am trying to expand this handy, but basic feedback widget: http://experiments.hertzen.com/jsfeedback/

That lives in the window namespace and POSTs to a blob server. I would like to be able to look into the router history of my Durandal app and send a snapshot back with my regular feedack object.

Can anyone advise on how this could be done?

note: since the Durandal 2.0 router is similar to Backbone.js, suggestions from Backbone devs might also be helpful.

I'm thinking of something like this:

durandalRouter.on('router:navigation:composition-complete') .then((instance: string, instruction: DurandalRouteInstruction, router: DurandalRouter) => { // todo: track history... });

glibaudio
  • 83
  • 1
  • 9

1 Answers1

1

You've basically got the answer. You would instantiate an array, preferably as a module, but alternatively as a global variable:

window.appHistory = [];

Then. you would set up event listening on your router that appends the instruction argument to the history.

router.on('router:navigation:complete')
    .then(function(instance, instruction, router) => {
        appHistory.push(JSON.stringify(instruction));
    };

The instruction object looks something like this.

{
    "fragment": "",
    "queryString": null,
    "config": {
        "title": "Home",
        "route": "",
        "moduleId": "viewmodels/home",
        "hash": "#",
        "routePattern": {}
    },
    "params": [],
    "queryParams": null
}
Matthew James Davis
  • 12,134
  • 7
  • 61
  • 90