2015-11-03 60 views
1

基於問題Multiple Aurelia apps on one page上,有沒有奧裏利亞辦法使同一頁上的兩個應用程序異步工作,這是類似奧裏利亞.two-way方法針對兩種不同的視圖模型。多個Aurelia大街之間的數據移動應用程式一個頁面

例如:

在應用程序A I使用.post方法與aurelia-http-client傳遞this.data = {"data": this.item};其中item綁定到文本輸入。作爲回報,我從API獲得containerId。現在,在應用BI想與.get方法使用相同的containerId用於獲取data張貼在應用A.

後來我想與.put方法,這意味着每當我使用的應用程序是一個更新的數據使用的應用程序A和應用B異步將在應用程序B中自動更新。

回答

0

您可以創建「共享狀態」模塊(或模塊)並根據需要導入它們。

Here's a working plunker

下面的代碼:

共享state.js

export var sharedState = { 
    foo: 'foo', 
    bar: 'bar', 
    baz: 'baz' 
}; 

app1.js

import {sharedState} from './shared-state'; 

export class App { 
    name = 'App 1'; 
    state = sharedState; 
} 

app2.js

import {sharedState} from './shared-state'; 

export class App { 
    name = 'App 2'; 
    state = sharedState; 
}