私がオープンソース化されますポーチ/ CouchDBのためのVueプラグインに取り組んでいますが、限り、私は私が午前問題を把握することができますよう:、VueJS Reactive Binding for Plugin - How To?
を現在私はVuexに似ていると密接にプラグインを作るしようとしています内部状態を持ち、変更を検出し、発生時にビューをレンダリングします。
Vueインスタンス内では、オブジェクトを初期化しています。そのオブジェクト内で、ここまではdefineReactiveを使って2〜3個のオブジェクトを反応させようとしています。
しかし、そのオブジェクトの中のいくつかの値を変更しようとすると、変更はビューに伝播されません。しかし、私が明示的にと呼んだ場合、$ bucket._state.projects .__ ob __。dep.notify()、変更が伝播します。 Vue { $bucket: { _state: { projects: {} } } }
$bucket._state
defineReactive
で初期化されています:
Vueのインスタンスの現在のオブジェクト表現は、このようなものです。私はそれがうまくいくはずだと信じていますが、私はこのケースで何が問題なのかよく分かりません。
コードの部分は、ここでのクラスは、私がこのような考えに深く潜るなかったVuex.Store({})
constructor(schema = {}) {
// Getting defineReactive from Vue
const { defineReactive } = Vue.util;
// Ignored Schema Keys
const ignoredKeys = [
'config',
'plugins'
];
// Internal Variables
this._dbs = {};
// Define Reactive Objects
defineReactive(this, '_state', {});
defineReactive(this, '_views', {});
// Local Variables
if (!schema.config) {
throw new Error(`[Pouch Bucket]: Config is not declared in the upper level!`);
}
// Init PouchDB plugins
if ((schema.plugins.constructor === Array) && (schema.plugins.length > 0)) {
for (let i = 0; i < schema.plugins.length; i++) {
PouchDB.plugin(
schema.plugins[i]
);
}
}
// Initializing DBs that are declared in the schema{}
for (const dbname in schema) {
if (schema.hasOwnProperty(dbname) && ignoredKeys.indexOf(dbname) === -1) {
this._initDB(
dbname,
Object.assign(
schema.config,
schema[dbname].config ? schema[dbname].config : {}
)
);
this._initState(dbname);
}
}
}