Reusable JavaScript in SPEAK
In my previous post I showed how to extend existing SPEAK models and views when creating new SPEAK components so we can reuse what we've already got rather than duplicating wads of code. Reuse at the view and model level is good but it's only one part of the puzzle. What about reusing individual functions? To reuse arbitrary code in C# we can wrap that code up in a class which can be called by other code files by way of a using statement (and appropriate references in the project). But JavaScript doesn't really have a native way to allow including existing functions from another location in the current file. It's normally up to the host environment how to get other files loaded in before the current file.