@@ -1749,16 +1749,54 @@ function valueInData<T>(data: any[], index: number, value?: T): T {
1749
1749
return value ! ;
1750
1750
}
1751
1751
1752
- /** Gets the binding at the current bindingIndex */
1753
- export function peekBinding ( ) : any {
1754
- ngDevMode && assertNotEqual ( currentView . bindingStartIndex , null , 'bindingStartIndex' ) ;
1755
- return data [ bindingIndex ] ;
1756
- }
1757
-
1758
1752
export function getCurrentQueries ( QueryType : { new ( ) : LQueries } ) : LQueries {
1759
1753
return currentQueries || ( currentQueries = new QueryType ( ) ) ;
1760
1754
}
1761
1755
1756
+ export function getCreationMode ( ) : boolean {
1757
+ return creationMode ;
1758
+ }
1759
+
1760
+ /** Gets the current binding value and increments the binding index. */
1761
+ export function consumeBinding ( ) : any {
1762
+ ngDevMode && assertDataInRange ( bindingIndex ) ;
1763
+ ngDevMode &&
1764
+ assertNotEqual ( data [ bindingIndex ] , NO_CHANGE , 'Stored value should never be NO_CHANGE.' ) ;
1765
+ return data [ bindingIndex ++ ] ;
1766
+ }
1767
+
1768
+ /** Updates binding if changed, then returns whether it was updated. */
1769
+ export function bindingUpdated ( value : any ) : boolean {
1770
+ ngDevMode && assertNotEqual ( value , NO_CHANGE , 'Incoming value should never be NO_CHANGE.' ) ;
1771
+
1772
+ if ( creationMode || isDifferent ( data [ bindingIndex ] , value ) ) {
1773
+ creationMode && initBindings ( ) ;
1774
+ data [ bindingIndex ++ ] = value ;
1775
+ return true ;
1776
+ } else {
1777
+ bindingIndex ++ ;
1778
+ return false ;
1779
+ }
1780
+ }
1781
+
1782
+ /** Updates binding if changed, then returns the latest value. */
1783
+ export function checkAndUpdateBinding ( value : any ) : any {
1784
+ bindingUpdated ( value ) ;
1785
+ return value ;
1786
+ }
1787
+
1788
+ /** Updates 2 bindings if changed, then returns whether either was updated. */
1789
+ export function bindingUpdated2 ( exp1 : any , exp2 : any ) : boolean {
1790
+ const different = bindingUpdated ( exp1 ) ;
1791
+ return bindingUpdated ( exp2 ) || different ;
1792
+ }
1793
+
1794
+ /** Updates 4 bindings if changed, then returns whether any was updated. */
1795
+ export function bindingUpdated4 ( exp1 : any , exp2 : any , exp3 : any , exp4 : any ) : boolean {
1796
+ const different = bindingUpdated2 ( exp1 , exp2 ) ;
1797
+ return bindingUpdated2 ( exp3 , exp4 ) || different ;
1798
+ }
1799
+
1762
1800
export function getPreviousOrParentNode ( ) : LNode {
1763
1801
return previousOrParentNode ;
1764
1802
}
0 commit comments