1
+ define ( [ 'exports' , 'aurelia-dependency-injection' , 'aurelia-templating' ] , function ( exports , _aureliaDependencyInjection , _aureliaTemplating ) {
2
+ 'use strict' ;
3
+
4
+ var _classCallCheck = function ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } } ;
5
+
6
+ exports . __esModule = true ;
7
+
8
+ var Compose = ( function ( ) {
9
+ function Compose ( container , compositionEngine , viewSlot , viewResources ) {
10
+ _classCallCheck ( this , _Compose ) ;
11
+
12
+ this . container = container ;
13
+ this . compositionEngine = compositionEngine ;
14
+ this . viewSlot = viewSlot ;
15
+ this . viewResources = viewResources ;
16
+ }
17
+
18
+ var _Compose = Compose ;
19
+
20
+ _Compose . prototype . bind = function bind ( executionContext ) {
21
+ this . executionContext = executionContext ;
22
+ processInstruction ( this , { view : this . view , viewModel : this . viewModel , model : this . model } ) ;
23
+ } ;
24
+
25
+ _Compose . prototype . modelChanged = function modelChanged ( newValue , oldValue ) {
26
+ var vm = this . currentViewModel ;
27
+
28
+ if ( vm && typeof vm . activate === 'function' ) {
29
+ vm . activate ( newValue ) ;
30
+ }
31
+ } ;
32
+
33
+ _Compose . prototype . viewChanged = function viewChanged ( newValue , oldValue ) {
34
+ processInstruction ( this , { view : newValue , viewModel : this . currentViewModel || this . viewModel , model : this . model } ) ;
35
+ } ;
36
+
37
+ _Compose . prototype . viewModelChanged = function viewModelChanged ( newValue , oldValue ) {
38
+ processInstruction ( this , { viewModel : newValue , view : this . view , model : this . model } ) ;
39
+ } ;
40
+
41
+ Compose = _aureliaDependencyInjection . inject ( _aureliaDependencyInjection . Container , _aureliaTemplating . CompositionEngine , _aureliaTemplating . ViewSlot , _aureliaTemplating . ViewResources ) ( Compose ) || Compose ;
42
+ Compose = _aureliaTemplating . noView ( Compose ) || Compose ;
43
+ Compose = _aureliaTemplating . bindable ( 'viewModel' ) ( Compose ) || Compose ;
44
+ Compose = _aureliaTemplating . bindable ( 'view' ) ( Compose ) || Compose ;
45
+ Compose = _aureliaTemplating . bindable ( 'model' ) ( Compose ) || Compose ;
46
+ Compose = _aureliaTemplating . customElement ( 'compose' ) ( Compose ) || Compose ;
47
+ return Compose ;
48
+ } ) ( ) ;
49
+
50
+ exports . Compose = Compose ;
51
+
52
+ function processInstruction ( composer , instruction ) {
53
+ composer . compositionEngine . compose ( Object . assign ( instruction , {
54
+ executionContext : composer . executionContext ,
55
+ container : composer . container ,
56
+ viewSlot : composer . viewSlot ,
57
+ viewResources : composer . viewResources ,
58
+ currentBehavior : composer . currentBehavior
59
+ } ) ) . then ( function ( next ) {
60
+ composer . currentBehavior = next ;
61
+ composer . currentViewModel = next ? next . executionContext : null ;
62
+ } ) ;
63
+ }
64
+ } ) ;
0 commit comments