Use an application manager singleton for formatting data. Allow for ability add multiple and custom formatters.
Would have a addFormatter(formatter) that would be added to an internal array of formatters.
When formatting is needed, the last formatter added with a matching function will be used to format the value. (LIFO)
For example, can use a formatPhoneUS(value, options) call to format a phone number in the US format. This would search the formatters for a function called phoneUS and call it with the arguments provided.
Use an application manager singleton for formatting data. Allow for ability add multiple and custom formatters.
Would have a
addFormatter(formatter)that would be added to an internal array of formatters.When formatting is needed, the last formatter added with a matching function will be used to format the value. (LIFO)
For example, can use a
formatPhoneUS(value, options)call to format a phone number in the US format. This would search the formatters for a function called phoneUS and call it with the arguments provided.