How do I know when to share?

To help make this determination, first ask yourself, is this applicable across multiple applications. If the answer is yes it's probably best to extract your code into a Javascript module or Service that can be pulled into other applications.

This can also be on a case by case basis.