JavaScript public subscribe example