Update mag.js

Added observer module pattern