exc-core

ExcCoreModule implements some static core features for the app and the communication between components, directives, services etc.

Usage no npm install needed!

<script type="module">
  import excCore from 'https://cdn.skypack.dev/exc-core';
</script>

README

Documentation

Module Exc-Core

ExcCoreModule implements some static core features for the app and the communication between components, directives, services etc.

Members

Array

Methods
Method Return Description
Get(array,value) any Gets the first entry from array matches to value
GetIndex(array,value) number Gets the index of the first entry from array matches to value
GetObject(array, key, value) any Gets the first entry from array of objects where the object[key] matches to value
GetObjectIndex(array, key, value) number Gets the index of the first entry from array of objects where the object[key] matches to value
GetAll(array, key, value) any[] Gets all entries from array of objects where the object[key] matches to value
Remove(array, value) any[] Removes the first element from the array matches to the value. Returns remaining array items
RemoveObject(array, key, value) any[] Removes the first element from the array matches to the value. Returns remaining array items
RemoveAll(array, value) any[] Removes all elements from the array matches to the value. Returns remaining array items
RemoveObjectAll(array, key, value) any[] Removes all elements from the array matches to the value. Returns remaining array items
Add(array, value) any[] Adds an element to the array. Returns result array
Merge(array1, array2) any[] Adds all elementes of array2 to array1. Returns merged array
Exists(array, value) boolean Search an array for an element matches to the value. Returns true or false
ExistsObject(array, key, value) boolean Search an array for an element where the object[key] matches to the value. Returns true or false
Distinct(array) any[] Removes duplicated items in array.
ExistsObject(array, key) any[] Removes duplicated items in array where the object[key] matches.

Guid

Methods
Method Return Description
NewGuid() string Generates a new uniqueidentifier (Guid)

Object

Methods
Method Return Description
Replace(destination,source) void Replaces all values in destination object from source object.
Keeps values in destination if they doesn't exist in source
Ignores values from source if they doesn't exist in destination
Merge(destination,...source) void Merges values from all source objects to destination object
DeepMerge(destination,...source) void Merges (recursive) values from all source objects to destination object

String

Methods
Method Return Description
Format(text,...args) string Formats a string and injects the arguments by index
Example
ExcCoreModule.String.Format("This {0} is crazy for {1}!","world","Robin") returns "This world is crazy for Robin!"
Reverse(text) string Reverses a given string

Methods

Method Return Description
on(name,callback) function Registers a callback function to a specified name as an event
call(name,...args) function Calls all callback functions for the specified name and tunnels all arguments to callback functions.
showInfo(message,title?) void Calls "eAM.ShowInfo" event. Listening to this event with
ExcCoreModule.on("eAM.ShowInfo",function(message,title){//Your code here});
showSuccess(message,title?) void Calls "eAM.ShowSuccess" event. Listening to this event with
ExcCoreModule.on("eAM.ShowSuccess",function(message,title){//Your code here});
showWarning(message,title?) void Calls "eAM.ShowWarning" event. Listening to this event with
ExcCoreModule.on("eAM.ShowWarning",function(message,title){//Your code here});
showError(message,title?) void Calls "eAM.ShowError" event. Listening to this event with
ExcCoreModule.on("eAM.ShowError []() ",function(message,title){//Your code here});
showModal(content,header?,size?,data?,closeViaOverlay?,footerButtons?) Observable Open a modal window as configured. Place content as string or place a component name
RegisterService(key,value) void Registers a value to ExcCoreModule.Services().
RegisterConfig(key,value) void Registers a value to ExcCoreModule.Config().
Services() any Gets all values registered by RegisterService(key,value)
Config() any Gets all values registered by RegisterConfig(key,value)

Module Exc-Translation

Exc-Translation is a class for translation of text resources. All other classes using translation have to extend this class

Usage: export class ClassName extends ExcTranslation

After this you have the option to use translations in ClassName

Methods

Method Return Description
getCurrentLang() string Get current selected language as string
onLangChange Observable Define a callback function which is called at language change
getRessource(name,param?) string Get a text resource of the current ClassName and the selected language. You can use placeholders in translation file to pass params to specific positions
getGlobal(name,param?) string Get a global text resource and the selected language. You can use placeholders in translation file to pass params to specific positions
getTranslation(name,param?) string Get text resource from root position and the selected language. You can use placeholders in translation file to pass params to specific positions