Coder Social home page Coder Social logo

kronin's Introduction

Krōnin

A collection of Rōnin extensions to enhance the Kony SDK.

Install

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.

node_modules and Krōnin as Vis app groups.

kony.amplify

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:

allowDuplicates(boolean)

Set whether or not to allow the same function to subscribe more than once to a topic. By default this is set to false.

getSubscriptions(string)

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]

isSubscribed(string, function)

Returns whether a specific function is subscribed to a topic.

function onFoo(){}
kony.amplify.subscribe("foo", onFoo);
kony.amplify.isSubscribed("foo", onFoo);
//true

kony.application

setAppBarColor(string)

Sets the color of the Android application bar at the top on the screen.

kony.application.setAppBarColor("cc0000");

kony.os

  • getOs()
  • isAndroid()
  • isIos()
  • isWeb()

kony.i18n

getLocalizedString2(string, object)

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!

kony.mvc

genAccessors(controller, Array)

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
		}
	}
}

patch(controller)

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.
		}
	};
});

kony.router

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()

kony.ui

getDescendants(containerWidget, includeParent, function)

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.

getComponents(containerWidget, includeParent)

A convenience function equivalent to using getDescendants with a filter to select component instances only.

Disclaimer

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 ;)

Contribute

To figure out how to build Krōnin for development check out CONTRIBUTE.md.

kronin's People

Contributors

mig82 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wamuko

kronin's Issues

priorForm.id is not an object on iOS

On iOS, attempting to reference the prior form after the navigation is invoked is causing an error priorForm.id null is not an object.

(new kony.mvc.Navigation(friendlyName)).navigate(context);
var priorForm = kony.application.getPreviousForm();
//Here's the problem.
if(!isGoingBack)_addToHistory(priorForm);

patch does not update router if controller doesn't have preShow function

If the form controller does not have a preShow function defined, then the kony.mvc.patch API does not invoke kony.router.setCurrent.
Need to account for scenarios where typeof controller.preShow === "undefined" and attach a dummy preShow function that at least invokes kony.router.setCurrent.

getComponents does not work on native

The kony.ui.getComponents API works on web channels but it does not work on native ones. Presumably because the name attribute of the widget that is expected to be kony.ui.KComponent is only actually present in the web framework.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.