Giter Site home page Giter Site logo

Use ngCookies about angular-tour HOT 9 CLOSED

daftmonk avatar daftmonk commented on July 30, 2024
Use ngCookies

from angular-tour.

Comments (9)

DaftMonk avatar DaftMonk commented on July 30, 2024

Yes, I actually have made some changes to this to do just that, as well as clean up the code so cookies are more optional.

I say more optional because I haven't figured out a way to have an optional dependency in a module with angularJS, so even if you disable cookies you still will need a angular-cookie script somewhere in your app. But I would like there to be a viable alternative to using the tour with cookies.

I'll push that a little later today, I want to go over it a bit first and see if it needs any more tests.

Edit: Oh I see you said ngCookies. Actually what I was talking about was using angular-cookie, https://github.com/ivpusic/angular-cookie. ngCookie unfortunately doesn't let you set the cookies expiration date, which makes it useless for this purpose :(

from angular-tour.

timelf123 avatar timelf123 commented on July 30, 2024

Ohh didn't realize that ngCookies doesn't let you set things like that - how pointless.

As far as an optional dependency, what about something like this:

try {
    cookie.function(args);
} catch (e) {
    if (!(e instanceof ReferenceError)) {
        throw e;
    }
}

Basically if cookie.function is not available because of a ReferenceError, nothing will be thrown.

from angular-tour.

DaftMonk avatar DaftMonk commented on July 30, 2024

The problem is with the angular module system though. To be able to inject the cookie service into my services I need to register the cookie module with angular, e.g.

angular.module('angular-tour', ['cookieModule']);

If the cookie module isn't included in the app, angular will throw an error that I don't think I can catch.

from angular-tour.

timelf123 avatar timelf123 commented on July 30, 2024

ahh. missed the point there. i'm not sure how to overcome that. thanks for the continued work on angular-tour! looking forward to seeing your latest work

from angular-tour.

DaftMonk avatar DaftMonk commented on July 30, 2024

I've thought about this a little more and I'd love to get your feedback on this.

I'm thinking about just removing cookies altogether from the tour, and have a tour directive just keep track of the currentStep. If the current step is greater than the number of steps in the tour, it is assumed to be completed.

This would solve a lot of the problems with flexibility, as you can use whatever storage method you want to save the currentStep, and load the tour from that.

from angular-tour.

DaftMonk avatar DaftMonk commented on July 30, 2024

Sorry I won't be able to get this up today. Since I've changed my approach its going to take longer than I thought to have something working. I'll try to push a working version tomorrow though :)

from angular-tour.

timelf123 avatar timelf123 commented on July 30, 2024

No problem! I like the idea of getting rid of cookies - a flexible storage adapter opens up lots of possibilities

from angular-tour.

dv336699 avatar dv336699 commented on July 30, 2024

@DaftMonk I'm with you. It's up to the developer to use ngCookies, angular-cookie, web storage or whatever.

Thanks for the great tool.

from angular-tour.

DaftMonk avatar DaftMonk commented on July 30, 2024

Finally got the chance to release the version with the changes I talked about. Take a look at the updated demo/readme for example usage. Let me know how it works :)

from angular-tour.

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.