1.

What is the name of a logic which involves managing the state which changes over time? Give an example.

Answer»
  • Stateful logic -  involves managing the state which changes over time. It is concerned with data that is of a different state whose state is changing every time. Stateless logic involves a record of previous interactions and every INTERACTION request has to be handled based on information not only from the request but the previous ONE also. 

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})}}


Discussion

No Comment Found

Related InterviewSolutions