Update observer.js

Adding sample code.