InterviewSolution
Saved Bookmarks
| 1. |
What is the name of a logic which involves managing the state which changes over time? Give an example. |
Answer»
Example: TRACKING the position of some moving object, as the time passes if something is in motion then its position is changing. So we can say the position has a different state and a logic performing MANIPULATION on the position is called stateful logic. // eventBus.jsimport Vue from 'vue'export const bus = new Vue()// component_one.vueimport { bus } from './eventBus.js'export default { data() { RETURN { value: null } } methodcreated() {// Listens for the 'action' eventbus.$on('action', ({ payload }) => { this.value = payload })}}// component_two.vueimport {bus} from './eventBus.js'export default {created() {// Emits the 'action' eventbus.$emit('action', {myPayload: 45678})}} |
|