Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alight declarative interface #210

Open
rumkin opened this issue Dec 22, 2016 · 4 comments
Open

Alight declarative interface #210

rumkin opened this issue Dec 22, 2016 · 4 comments

Comments

@rumkin
Copy link

rumkin commented Dec 22, 2016

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() {}
})();
@lega911
Copy link
Owner

lega911 commented Dec 22, 2016

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: () => {}
})

@rumkin
Copy link
Author

rumkin commented Dec 23, 2016

What is direct-directives? How to define it?

@rumkin
Copy link
Author

rumkin commented Dec 23, 2016

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

@rumkin
Copy link
Author

rumkin commented Dec 24, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants