この質問の仕方が少しわからないので、今いるところからできる限りのことを始めます。私はデータ型を持っています。これを「プログラム」と呼びます。これは、単一のデータソースからいくつかのコア情報をロードします。中央データ モデルの読み込み/キャッシュ ロジックを作成しましたが、プロジェクト設定に基づいて、フレームワークがデータ モデルに追加する必要がある外部から読み込まれたノードがあります。
私が探しているのは、プロジェクトで必要な場合にこれらの追加されたデータ ノードをロードし、すべてのデータがロードされるまでプログラムを実行しないようにする設計パターンです。ノードがどのようなものになるか、必要になったときにどこでデータを取得するかを事前に知っていると想定できます。私の現在の設定は以下のようになります。
var programs = {},
loadCuePoints = function (uuid, callback) {
//will call the callback with the data once loaded and add the program
//to programs, keyed by the uuid
},
loadLinkedFiles = function (uuid, callback) {
//will append the data to programs[uuid] and call the callback with the
//data once loaded
},
loadProgram = function (uuid, callback) {
//will append the data to programs[uuid] and call the callback with the
//data once loaded
},
// hash where the key is the node on program and the value is the function
// used to load the data, this will be based on project settings, but I'm not
// concerned with this logic for this question
requiredData = {
cuePoints : loadCuePoints,
linkedFiles : loadLinkedFiles
},
getProgram = function(uuid, callback) {
if (programs[uuid]) {
callback(programs[uuid]);
} else {
//assume the key in the requiredData hash is the required node on
//Program, and that the value is the callback method, the functions
//in this table sre already set up to load the data and return it
//via the callback once loaded
}
}
私は確かにこれをハックすることができるので、解決策をあまり求めていません (非常にうまく機能するものや特にエレガントなものがない限り)。非同期アクションのコレクション。説明が不明確な場合は、詳しく説明していただければ幸いです。