Call on_assignment and perform rebalance when using js

Includes a nice refactor.
Merge pull request #172 from tmandry/assignment-callback-js

Call on_assignment and perform rebalance when using js