Giter Site home page Giter Site logo

clearAll() method about ember-cookies HOT 8 CLOSED

mainmatter avatar mainmatter commented on July 19, 2024
clearAll() method

from ember-cookies.

Comments (8)

marcoow avatar marcoow commented on July 19, 2024 1

@geekygrappler: I think you were working on a PR?

from ember-cookies.

marcoow avatar marcoow commented on July 19, 2024

Should that be a test helper maybe? Also we could think about not actually writing any cookies in the test environment at all but only store everything in memory so that tests would leave no traces. That would break cases where external JS libraries would actually require a cookie that'd be written through ember-cookies.

from ember-cookies.

Turbo87 avatar Turbo87 commented on July 19, 2024

I think a clearAll() might also be useful outside the context of testing, and making it something different than a simple method on the existing service will increase the complexity of the API quite a bit.

I guess having pluggable adapters as the base for this addon might be an interesting thing to explore given that we already have browser and fastboot adapters.

from ember-cookies.

marcoow avatar marcoow commented on July 19, 2024

I think a clearAll() might also be useful outside the context of testing

I think this might lead to all kinds of problems potentially as you'd delete all cookies, not just the ones written via ember-cookies (but also ones written by other libraries, set by the server etc.).

and making it something different than a simple method on the existing service will increase the complexity of the API quite a bit.

Hm, wouldn't that just be

import clearAllCookies from 'ember-cookies';

clearAllCookies();

I guess having pluggable adapters as the base for this addon might be an interesting thing to explore given that we already have browser and fastboot adapters.

This would make ember-cookies seriously more complex though so let's see whether we see an actual use case for this.

from ember-cookies.

cafreeman avatar cafreeman commented on July 19, 2024

+1 on this. I came to the issues here looking for this exact thing because I'm trying to figure out how to reset cookies in start-app. Even if there wasn't a clearAll, it'd be nice to be able to import read, write, and clear as separate functions independent of the service for use in tests.

from ember-cookies.

geekygrappler avatar geekygrappler commented on July 19, 2024

I've done some investigation. When reading a cookie, we only get the key value pair, and not the path, which means I don't think a clearAll() method would be able to pass a cookies path.

So if we had a cookie which was test=val and it was on path /testing, a read would give us {test: val} and then if we called clear(test) it might not be cleared, because we didn't pass the path. If no path is passed the current path is used. e.g. if we were on /testing/some/other/path then the /testing cookie wouldn't be deleted, if we were on /testing it would be.

Is this an acceptable limitation?

from ember-cookies.

marcoow avatar marcoow commented on July 19, 2024

I think we should still allow passing options to clearAll. The purpose of ember-cookies is really just to provide an API for cookie that works in the browser as well as in FastBoot without doing anything else really or adding anything in addition to that abstraction layer. That said, I think if anyone knows all the options for all the cookies they want to clear we shouldn't stand in the way and let them pass them to clearAll.

from ember-cookies.

dzbo avatar dzbo commented on July 19, 2024

I've also faced issues with cookies in acceptance tests. Would be great to have that clearAll option :)

from ember-cookies.

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.