How Stuffs Work

Yo! Straight to the topic of how the core of Empathy works like.

First, there is an object canned You. The name Empathy comes in direct relation to You. As anyone uses Empathy, he/she can scream (*with excitement*) at the app: “You made me feel better!”

Then there are brains. Did you know that humans have two hemispheres of brain that perform different tasks? Yeah, well, Empathy has too(except it can hold any number of Brains)! Each Brain is meant to do one particular stuff, like, one Brain handles all life events in the screen and another Brain might be analysing how the user reacts. And when two Brains need to intercommunicate, they emit and listen to Events.

Now, let’s get down to the stuffs that appear on the screen. They’re called LifeEvents because they are meant to come and go in life. Each LifeEvent is [meant to be] created by You and You is controlled by Brains. Each LifeEvent has onCreate(), onRun(), onFinish() and onDestroy() methods which can be overidden to serve your needs. Let’s consider a flower moving away in screen. During the onCreate() phase, make it fade in, and onRun() phase, calculate its movement and during the onFinish() phase, make it fade out, it’s that simple!

Do you remember asynchronous timed events in JavaScript: setInterval(fun) and setTimeout(fun)? Yeah, well they are here too! But a little complex. Check out the docs!

Here’s the demo: