remove obsolete methods

pull/1348/head
Rich Harris 7 years ago
parent 5ebd43898c
commit 470eacf9d4

@ -51,13 +51,8 @@ export function fire(eventName, data) {
} }
} }
export function getDev(key) { export function get() {
if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); return this._state;
return get.call(this, key);
}
export function get(key) {
return key ? this._state[key] : this._state;
} }
export function init(component, options) { export function init(component, options) {
@ -69,34 +64,6 @@ export function init(component, options) {
component.store = component.root.store || options.store; component.store = component.root.store || options.store;
} }
export function observe(key, callback, options) {
var fn = callback.bind(this);
if (!options || options.init !== false) {
fn(this.get()[key], undefined);
}
return this.on(options && options.defer ? 'update' : 'state', function(event) {
if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]);
});
}
export function observeDev(key, callback, options) {
console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package");
var c = (key = '' + key).search(/[.[]/);
if (c > -1) {
var message =
'The first argument to component.observe(...) must be the name of a top-level property';
if (c > 0)
message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'";
throw new Error(message);
}
return observe.call(this, key, callback, options);
}
export function on(eventName, handler) { export function on(eventName, handler) {
if (eventName === 'teardown') return this.on('destroy', handler); if (eventName === 'teardown') return this.on('destroy', handler);
@ -193,31 +160,27 @@ export function removeFromStore() {
} }
export var proto = { export var proto = {
destroy: destroy, destroy,
get: get, get,
fire: fire, fire,
observe: observe, on,
on: on, set,
set: set,
teardown: destroy,
_recompute: noop, _recompute: noop,
_set: _set, _set,
_mount: _mount, _mount,
_unmount: _unmount, _unmount,
_differs: _differs _differs
}; };
export var protoDev = { export var protoDev = {
destroy: destroyDev, destroy: destroyDev,
get: getDev, get,
fire: fire, fire,
observe: observeDev,
on: onDev, on: onDev,
set: setDev, set: setDev,
teardown: destroyDev,
_recompute: noop, _recompute: noop,
_set: _set, _set,
_mount: _mount, _mount,
_unmount: _unmount, _unmount,
_differs: _differs _differs
}; };

Loading…
Cancel
Save