The assign function triggers Mahalo's change detection. Howeverwhen writing your application in TypeScript you don't have to takecare of this yourself and won't need to use this function at all.
In the following examples you can see different assignments an theircounterparts using assign.
let foo = 0;let bar = 0;let baz = {x: 0};// Variable assignments are just wrapped++foo; // 1assign(++foo); // 2foo + (bar = 10); // bar 12foo + assign(bar = 10); // 12// Member assignments must be explicitfoo + baz.x++; // 2foo + assign(baz, 'x', baz.x + 1); // 3
Finds a value along a given path or sets a value in the given pathwhen called with a third argument.
A key path is a chain of keys to follow inside of an object. They aresepareted by a dot. If your key actually contains a dot you canescape it with the ^ symbol. If you need an actual ^ symbolin a key you can use ^^. You get the idea.
Remove a callback for a key path, remove all callbacks for a key pathinside of an object or unwatch the object entirely.
See keyPath for more information about valid key paths.
Watch a key path inside of an object and execute a givencallback when the value changes.
See keyPath for more information about valid key paths.
Mahalo's configuration object. It's a simple map thatyou can read from but also write to.
The path to your application where '/' is the web root.
The attribute name that will be used to attach the Classesbehavior to elements with that attribute.
The attribute name that will be used to attach the Contentbehavior to elements with that attribute.
The default format for dates if no other is specified.
The selector that will be used to select elements thatshould use the For component.
The attribute name that will be used to attach the Linkbehavior to elements with that attribute.
The attribute name that will be used to attach the Modelbehavior to elements with that attribute.
The default format for numbers.
The selector that will be used to select elements thatshould represent a Route.
The selector that will be used to select elements thatshould use the Show component.
The attribute name that will be used to attach the Stylesbehavior to elements with that attribute.
This is the filters object that will be used to lookfor filters in expressions. It's a plain JS object soyou can just import it, use its methods as you see fit,add custom filters to it or even overwrite the defaultones.
Converts a hyphenated or underscored string to camel-case.
Converts a given value to a date in a givenformat orthe default one from the config.
Currently the following tokens are supported:
Filters an array by a given value or undefined. If an optional key isgiven as third argument it will try to use that key fromtha array's values.
Converts a camel-cased string to a hyphenated one.
Converts a string to lower-case letters.
Converts a value to number in a optionally give format orthe default one from the config.
The format will be parsed from one of the following orfallback to an integer:
Basically the algorithm is to use any non numeric characterfrom the 2 position in the string as thousands separator ifavailable. The last non numeric character from the end willbe used the decimal point and the number of numeric charactersat the end of the string will be used as precision.
Pads a string on its left side with an optional givencharacter or 0.
Sorts an array. An optional key can be given as second parameterthat will be looked up on the array's values for comparison.A third argument allows for changing the sort order to descending.
Converts a camel-cased string to a underscored one.
Converts a string to upper-case letters.
The main module of Mahalo. In general everything you need towork with when creating Mahalo applications can be importedfrom here.
All exports of mahalo can be considered public. You mightfind more goodies in other places of Mahalo's source theycould change in the future.