call onstatechange with an object, closes #12