GithubHelp home page GithubHelp logo

$state.loaded about ui-router HOT 7 CLOSED

timkindberg avatar timkindberg commented on August 24, 2024
$state.loaded

from ui-router.

Comments (7)

ksperling avatar ksperling commented on August 24, 2024

There is currently a $state.transition property, which is a promise for the next state, i.e. it is resolved when the state transition completes (or rejected if it fails). $state.transition is never null.

The way things are currently implemented, views only update once all dependencies are resolved. This is because the view directive needs to create the controller at the time the view is created, and the controller needs the dependencies.

I was thinking of having a $state.next property which is non-null only if there is currently a transition in progress, so that you could use that to display a loading indicator (this would probably be done in a global place outside any ng-view) with something like ``ng-show="$state.next"`

from ui-router.

timkindberg avatar timkindberg commented on August 24, 2024

I'm not sure that $state.next says Boolean to me. I would assume it would be a state object of the next state being loaded. I think we need a loaded property; I hate to play this card, but ember's routes have them and they use them quite a bit in examples. I just think people are going to be looking for it. I think it's so common that we need a nice obvious solution for it.

from ui-router.

ksperling avatar ksperling commented on August 24, 2024

yeah next wouldn't be a boolean, but you could use it as one -- it would be non-null if transition is in progress.

We could call it 'loading' rather than next?

That would also let you do something along the lines of <div ng-show="{{$state.loading}}">Loading {{$state.loading.title}}"</div> if you had a custom 'title' property on your states.

I think providing access to the state that's being loaded can be very useful compared to just a boolean.

from ui-router.

timkindberg avatar timkindberg commented on August 24, 2024

Hey I like that! I just think people will be looking for a loading
property, but that is even more powerful.

Man, its just that it may not be as clear as just having two separate
properties, both loaded and loading. Its the kind of thing where if we only
had 'loading' we'd HAVE to put it in our documentation that you can use it
in ng-show. And it would be this thing where theres 50 stack overflow
questions about it and always the same answer "use $state.loading" "Oh cool
thanks!". Where as if we had a "loaded" boolean property people would find
and use it easily. So I think if it wasn't too much extra work we may want
to do both "loaded" and "loadingState" ("loading" feels too much like a
state of $state). We should see what others think too, since we are going
back and forth on this.

On Sat, Feb 16, 2013 at 10:53 PM, Karsten Sperling <[email protected]

wrote:

yeah next wouldn't be a boolean, but you could use it as one -- it would
be non-null if transition is in progress.

We could call it 'loading' rather than next?

That would also let you do something along the lines of

Loading {{$state.loading.title}}"
if
you had a custom 'title' property on your states.

I think providing access to the state that's being loaded can be very
useful compared to just a boolean.


Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/router/issues/23#issuecomment-13680316.

Thanks,

Tim Kindberg

from ui-router.

ksperling avatar ksperling commented on August 24, 2024

I guess we can put 'loaded' down on the nice-to-have conveniences list... I'd just like to get the essential APIs and then see how many of the things we now predict will be very convenient really are.

If I saw both 'loaded' and 'loading' in the API docs I'd wonder if their semantics differ in some subtle way or why else somebody would add a property that's only saving a single negation.

I've previously worked with the rule that in order to be "allowed" to add a utility / convenience method or property on top of an existing API, you have to have done it the pedestrian way at least three times first. I think we should follow a similar approach and get some real world use of the bare-bones API and then see where the convenience APIs would really be useful in practice.

from ui-router.

timkindberg avatar timkindberg commented on August 24, 2024

That's fair.

from ui-router.

stale avatar stale commented on August 24, 2024

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

from ui-router.

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.