A collection of Rōnin extensions to enhance the Kony SDK.
Krōnin is published to the NPM Registry so you can just install it into your project using the NPM command line by stepping into the project's root directory and running:
npm install kronin --prefix modules
This will install Krōnin into [project_root]/modules/node_modules/kronin
. Then in Visualizer click Project/Refresh. Visualizer will pick up the node_modules
and kronin
directories as application groups.
An adaptation of AmplifyJS's PubSub Core, this namespace allows you to leverage the PubSub pattern in your applications. Like AmplifyJS, this supports these three functions:
- publish
- subscribe
- unsubscribe
Additionally, this adaptation offers these three additional methods:
Set whether or not to allow the same function to subscribe more than once to a topic. By default this is set to false
.
Returns an array of all the functions subscribed to a topic.
function onFoo(){}
function onFoo2(){}
kony.amplify.subscribe("foo", onFoo);
kony.amplify.subscribe("foo", onFoo2);
kony.amplify.getSubscriptions("foo");
//[onFoo, onFoo2]
Returns whether a specific function is subscribed to a topic.
function onFoo(){}
kony.amplify.subscribe("foo", onFoo);
kony.amplify.isSubscribed("foo", onFoo);
//true
Sets the color of the Android application bar at the top on the screen.
kony.application.setAppBarColor("cc0000");
- getOs()
- isAndroid()
- isIos()
- isWeb()
Get the localised string for an i18n key or return the key itself if none exists for the current locale. This is useful because if there are gaps in a language bundle, seeing the actual key on screen helps identify the missing translations — as opposed to just seeing a blank and wondering what the key is.
This function also supports substitution variables specified with curly brackets — e.g.:
If the localised string of an i18n key message.greeting
is Hello {name}, count to {count}!
, then:
kony.i18n.getLocalizedString2("message.greeting", {
"name": "Miguel",
"count": 3
});
//Hello Miguel, count to 3!
Define a component's setters and getters for any custom fields in one line by just listing the fields -e.g. This could be the body of a component's controller.:
define(function() {
return{
constructor: function() {/*...*/},
initGettersSetters: function() {
kony.mvc.genAccessors(this, ["foo","bar"]);
//Defines accessors getFoo, setFoo, getBar and setBar
}
}
}
Binds any init
, preShow
, postShow
or onHide
functions defined in the current controller to the corresponding view's life cycle events, without having to use actions or additional code to do it.
These functions are also bound with a wrapping try/catch
statement, so that if there are syntax errors in the functions defined, they'll be easier to debug -e.g. This could be the body of a forms's controller.:
define(function(){
return{
init: function(){/*...*/},
preShow: function(){/*...*/},
postShow: function(){/*...*/},
onHide: function(){/*...*/},
onNavigate: function(){
kony.mvc.patch(this);
//Now init, preShow, postShow, onHide are all bound.
}
};
});
A convenient way to do all the navigations from a centralised place, which also provides
a history of the navigations, allowing you to go back in a logical way.
When used along with kony.mvc.patch
this router also allows you to query which the current form is — something that's not readily possible in MVC projects.
- init(maxHistorySize)
- goTo(formIdOrFriendlyName, context, isGoingBack)
- getCurrent()
- goBack(context)
- goHome(context)
- getHistory()
Returns an array containing all the widgets nested within a form or container widget. The container widget may be a Form, a Flex Container, Scroll Flex Container or any other widget capable of containing other widgets.
It also allows you to specify a function to filter which children should be included in the result. The filtering function must be one returning a boolean
.
kony.ui.getDescendants(this.view.flxTop, true, (child) => {
return child.id.substring(0,3) === "flx";
});
//[flxTop, ...] including any child of flxTop named with an "flx" prefix.
A convenience function equivalent to using getDescendants
with a filter to select component instances only.
Krōnin is meant as a community project. It is Not part of the Kony Platform and it's not supported by Kony Inc. in any way — Hence the Rōnin bit ;)
To figure out how to build Krōnin for development check out CONTRIBUTE.md.