angular-light icon indicating copy to clipboard operation
angular-light copied to clipboard

Alight declarative interface

Open rumkin opened this issue 9 years ago • 4 comments

Add declarative interface:

alight.namespace('ns')
.directive('name', {link})
.directives({
    dirName: {link}
})
.controller(name, fn)
.controllers({
    ctrlName(scope) {/*...*/}
});
// filters are the same

Namespace create alight new namespace or use existing. It is pretty and simple.

Extended example:

(function() {
    'use strict';

    alight.namespace('ns')
    .controllers({userCtrl, settingsCtrl});

    function userCtrl() {}
    function settingsCtrl() {}
})();

rumkin avatar Dec 22 '16 12:12 rumkin

Hi!

I don't very like this Angular 1 style, but I can add it to "ext" package. Also filters doesn't have namespace, controllers were removed, now direct-directives instead of them. Also filters and direct-directives can be located in scope, so you don't need always create namespaces, e.g.:

alight('body', {
  data: '',
  filter: (a, b) => a+b,
  directive: () => {}
})

lega911 avatar Dec 22 '16 21:12 lega911

What is direct-directives? How to define it?

rumkin avatar Dec 23 '16 13:12 rumkin

Declarative interface is about to avoid ugly constructions like alight.directives.ns = alight.directives.ns || {}; in modular applications.

rumkin avatar Dec 23 '16 13:12 rumkin

And about namespaces itself. It very important to separate code into modules. Namespaces is the best trick to avoid conflicts. I have two different projects where I've realised toDate filters but they parsed different date formats which cause an error. This make me to rewrite one of the components.

rumkin avatar Dec 24 '16 14:12 rumkin