Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($cookies): remove the deprecated $cookieStore factory #16465

Merged
merged 1 commit into from Mar 13, 2018

Conversation

mgol
Copy link
Member

@mgol mgol commented Feb 21, 2018

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix - a removal of a deprecated factory.

What is the current behavior? (You can also link to an open issue here)

The $cookieStore factory exists.

What is the new behavior (if this is a feature change)?

It doesn't.

Does this PR introduce a breaking change?

Yes.

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Fix/Feature: Docs have been added/updated
  • Fix/Feature: Tests have been added; existing tests pass

Other information:

BREAKING CHANGE:

The $cookieStore has been removed. Migrate to the $cookie service. For simple
values it's enough to rename $cookieStore to $cookie; for object values you need
to use the putObject & getObject methods.

Before:

$cookieStore.put('name1', 'simple value');
$cookieStore.get('name1'); // 'simple value'
$cookieStore.remove('name1');
$cookieStore.put('name2', {key: 'value'});
$cookieStore.get('name2'); // {key: 'value'}
$cookieStore.remove('name2');

After:

$cookie.put('name1', 'simple value');
$cookie.get('name1'); // 'simple value'
$cookie.remove('name1');
$cookie.putObject('name2', {key: 'value'});
$cookie.getObject('name2'); // {key: 'value'}
$cookie.remove('name2');

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make the following changes to the commit message:

  1. fix($cookies) --> fix(ngCookies) (because you are not really changing $cookies)
  2. $cookie --> $cookies (everywhere)
  3. It might be simpler to drop the differentiation between simple and object values and just recommend $cookies.get/putObject() (since this is what $cookieStore was using under the hood.
    At least, we should mention that $cookies.get() will not correctly retrieve simple values stored with $cookieStore.put() (since the stored values will be JSON-stringified and need to be JSON-parsed).

<li>The {@link ngCookies.$cookies $cookie} service is a convenient wrapper to store simple data within browser cookies.</li>
<li>{@link ngCookies.$cookieStore $cookieStore} is used to store more complex data using serialization.</li>
</ul>
The {@link ngCookies.$cookies $cookie} service is a convenient wrapper to store simple data within browser cookies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$cookie --> $cookies

BREAKING CHANGE:

The $cookieStore has been removed. Migrate to the $cookies service. Note that
for object values you need to use the `putObject` & `getObject` methods as
`get`/`put` will not correctly save/retrieve them.

Before:
```js
$cookieStore.put('name', {key: 'value'});
$cookieStore.get('name'); // {key: 'value'}
$cookieStore.remove('name');
```

After:
```js
$cookies.putObject('name', {key: 'value'});
$cookies.getObject('name'); // {key: 'value'}
$cookies.remove('name');
```
@mgol
Copy link
Member Author

mgol commented Mar 12, 2018

@gkalpak PR updated.

@mgol mgol merged commit 73c6467 into angular:master Mar 13, 2018
@mgol mgol deleted the cookie-store branch March 13, 2018 08:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants