Giter VIP home page Giter VIP logo

Comments (6)

KidkArolis avatar KidkArolis commented on June 21, 2024

Its only called when transitioning away from the route - its actually an
event and not a regular method, I should probably make it look more like
that. Activate is called when entering the route.
I'll clarify the docs.

I may just have a misunderstanding of the purpose of willTransition here,
but I would have thought that willTransition would be called whenever a
transition occurs?

Example of what I am seeing:

router.addRoute("foo", Route.extend({
willTransition: function () {
console.log('bar');
}
});

router.startRouting();
router.transitionTo("foo");
router.transitionTo("foo");

The above example will only log bar once.


Reply to this email directly or view it on GitHub
#38.

from cherrytree.

oliverwoodings avatar oliverwoodings commented on June 21, 2024

Ohhhh ok that makes sense. So can you do transition.abort in activate?

from cherrytree.

KidkArolis avatar KidkArolis commented on June 21, 2024

I think beforeModel or model hooks are best for redirects if that's what
you're trying to do. Abort in activate might work, not sure.
On Aug 6, 2014 9:06 AM, "Oliver Woodings" [email protected] wrote:

Ohhhh ok that makes sense. So can you do transition.abort in activate?


Reply to this email directly or view it on GitHub
#38 (comment)
.

from cherrytree.

oliverwoodings avatar oliverwoodings commented on June 21, 2024

Yeah basically I don't want to go into a certain resource if the user isn't authenticated since fetching the models won't work unless you are authenticated

from cherrytree.

KidkArolis avatar KidkArolis commented on June 21, 2024

BeforeModel is intended for such cases. Activate hook is called when all
routes have already resolved the model, so too late to redirect in your
case. Btw you don't need to abort, you can just call this.transitionTo and
the previous transition will be aborted automatically.
On Aug 6, 2014 10:02 AM, "Oliver Woodings" [email protected] wrote:

Yeah basically I don't want to go into a certain resource if the user
isn't authenticated since fetching the models won't work unless you are
authenticated


Reply to this email directly or view it on GitHub
#38 (comment)
.

from cherrytree.

KidkArolis avatar KidkArolis commented on June 21, 2024

I've slightly clarified the docs via @4dd29454a7ce608bfb82c943934d9f83ec98816a and added a new issue about making willTransition look more like an event #43

from cherrytree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.