Skip to content

Using and abstracting away libraries #237

Description

@GertSallaerts

I have a question regarding best practices concerning the usage of libraries (like jQuery, handlebars, underscore, ...)

The readme from the project states:
"Abstract away utility libraries you are using (templating, DOM manipulation) so that you can swap them out for alternatives at any time without a great deal of effort."

If I understand correctly, this would be done by using extensions that add the library's functionality to app.core, but in a way so as to make these extensions to core library-independent.

Example:

  • Library "a" has function "sum(x, y)" that adds x and y.
  • Library "b" has function "add(x, y)" that adds x and y.

Would you then create these extensions?

  • Extension "aura-a" that extends app.core.math with a function sum(x, y) which would execute the sum function from library "a"
  • Extenstion "aura-b" that extends app.core.math with a function sum(x,y) which would execute the add function from library "b"

If I am correct in my assumptions, are there any of these extensions already available? The aura-examples I've seen don't seem to use a lot of libraries yet, mostly underscore which is usually used directly instead of using an extension that adds underscore functionality to app.sandbox.util

One thing I've seen is the aura-handlebars extension in aura-todos:

initialize: function(app) {
    var Handlebars = require('handlebars');
    app.core.template.hbs = Handlebars;
  }

This seems to contradict my understanding of how extensions should be used since it just inserts handlebars as-is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions