Skip to content

Commit

Permalink
Merge pull request #1347 from sveltejs/deprecate-get-with-string
Browse files Browse the repository at this point in the history
deprecate get with string argument
  • Loading branch information
Rich-Harris authored Apr 17, 2018
2 parents 424bb1a + 5ebd438 commit 27f6241
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export function fire(eventName, data) {
}
}

export function getDev(key) {
if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead");
return get.call(this, key);
}

export function get(key) {
return key ? this._state[key] : this._state;
}
Expand Down Expand Up @@ -204,7 +209,7 @@ export var proto = {

export var protoDev = {
destroy: destroyDev,
get: get,
get: getDev,
fire: fire,
observe: observeDev,
on: onDev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function fire(eventName, data) {
}
}

function getDev(key) {
if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead");
return get.call(this, key);
}

function get(key) {
return key ? this._state[key] : this._state;
}
Expand Down Expand Up @@ -188,7 +193,7 @@ function _unmount() {

var protoDev = {
destroy: destroyDev,
get: get,
get: getDev,
fire: fire,
observe: observeDev,
on: onDev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function fire(eventName, data) {
}
}

function getDev(key) {
if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead");
return get.call(this, key);
}

function get(key) {
return key ? this._state[key] : this._state;
}
Expand Down Expand Up @@ -188,7 +193,7 @@ function _unmount() {

var protoDev = {
destroy: destroyDev,
get: get,
get: getDev,
fire: fire,
observe: observeDev,
on: onDev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function fire(eventName, data) {
}
}

function getDev(key) {
if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead");
return get.call(this, key);
}

function get(key) {
return key ? this._state[key] : this._state;
}
Expand Down Expand Up @@ -188,7 +193,7 @@ function _unmount() {

var protoDev = {
destroy: destroyDev,
get: get,
get: getDev,
fire: fire,
observe: observeDev,
on: onDev,
Expand Down

0 comments on commit 27f6241

Please sign in to comment.