Last active
March 15, 2017 05:16
-
-
Save SergeyAxenov/78e3355929b43ef93090cafb628c5cfd to your computer and use it in GitHub Desktop.
Zeppelin 0.6.2 angular watch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Sequence of binding events on angular watch | |
// 2. nulls are accepted as both initial and new value | |
// 3. using the same value (even null) twice triggers the watch | |
// 4. Multiple watchers on the same variable | |
// 5. Bug in watch (before, after) | |
// 6. Use watch (before, after, context) - it is working as expected | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
val logger: Logger = LoggerFactory.getLogger("MyZeppelinLogger"); | |
z.angularUnwatch("ax4_var") | |
logger.debug("Before binding"); | |
z.angularBind("ax4_var", null) | |
logger.debug("After binding. Before watch configured"); | |
z.angularWatch("ax4_var", (before, after, ctx) => { | |
logger.debug(s"Watch (before, after, ctx) triggered. Old value=$before New value=$after"); | |
}) | |
z.angularWatch("ax4_var", (before, after) => { | |
logger.debug(s"Watch (before, after) triggered. Old value=$before New value=$after"); | |
}) | |
logger.debug("Watch configured"); | |
// Triggers watch 1? | |
z.angularBind("ax4_var", null) | |
// Triggers watch 2? | |
z.angularBind("ax4_var", null) | |
// Triggers watch 3? | |
z.angularBind("ax4_var", "string for a change") | |
// Triggers watch 4? | |
z.angularBind("ax4_var", "new string") | |
// Log results: | |
// ... | |
//[DEBUG] 2017-03-15 04:40:10.093 [pool-2-thread-13] MyZeppelinLogger - Before binding | |
//[DEBUG] 2017-03-15 04:40:10.361 [pool-2-thread-13] MyZeppelinLogger - After binding. Before watch configured | |
//[DEBUG] 2017-03-15 04:40:10.898 [pool-2-thread-13] MyZeppelinLogger - Watch configured | |
//[DEBUG] 2017-03-15 04:40:11.035 [pool-24-thread-19] MyZeppelinLogger - Watch (before, after, ctx) triggered. Old value=null New value=null | |
//[DEBUG] 2017-03-15 04:40:11.036 [pool-24-thread-10] MyZeppelinLogger - Watch (before, after) triggered. Old value=null New value=null | |
//[DEBUG] 2017-03-15 04:40:11.168 [pool-24-thread-20] MyZeppelinLogger - Watch (before, after, ctx) triggered. Old value=null New value=null | |
//[DEBUG] 2017-03-15 04:40:11.168 [pool-24-thread-40] MyZeppelinLogger - Watch (before, after) triggered. Old value=null New value=null | |
//[DEBUG] 2017-03-15 04:40:11.277 [pool-24-thread-21] MyZeppelinLogger - Watch (before, after, ctx) triggered. Old value=null New value=string for a change | |
//[DEBUG] 2017-03-15 04:40:11.278 [pool-24-thread-11] MyZeppelinLogger - Watch (before, after) triggered. Old value=string for a change New value=string for a change | |
//[DEBUG] 2017-03-15 04:40:11.381 [pool-24-thread-22] MyZeppelinLogger - Watch (before, after, ctx) triggered. Old value=string for a change New value=new string | |
//[DEBUG] 2017-03-15 04:40:11.382 [pool-24-thread-44] MyZeppelinLogger - Watch (before, after) triggered. Old value=new string New value=new string | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment