allow observing $foo in dev mode - #1181

pull/1186/head
Rich Harris 7 years ago
parent 805c72fefc
commit cb8071acd4

@ -100,7 +100,7 @@ export function observe(key, callback, options) {
}
export function observeDev(key, callback, options) {
var c = (key = '' + key).search(/[^\w]/);
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';

@ -0,0 +1,25 @@
import { Store } from '../../../../store.js';
const store = new Store({
name: 'world'
});
export default {
store,
html: `<h1>Hello world!</h1>`,
dev: true,
test(assert, component) {
const names = [];
component.observe('$name', name => {
names.push(name);
});
store.set({ name: 'everybody' });
assert.deepEqual(names, ['world', 'everybody']);
}
};
Loading…
Cancel
Save