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

Simple JS functions on top of the Pengines JS API? #7

Open
torbjornlager opened this issue Jul 13, 2014 · 1 comment
Open

Simple JS functions on top of the Pengines JS API? #7

torbjornlager opened this issue Jul 13, 2014 · 1 comment

Comments

@torbjornlager
Copy link
Contributor

Food for thought: Maybe a couple of simple JS functions should be defined on top of the JS API? Here for example is a function that will populate a DOM element identified by idwith the answer(s) to goal:

function populate(template, goal, id) {
    var pengine = new Pengine({
        ask: goal,
        template: template,
        onsuccess: function() {
            document.getElementById(id).innerHTML = this.data[0]
        }
    });
    return pengine;
}

Test with:

p = populate("X", "member(X, [1,2,3])", "mydiv");
p.next();
p.next();

populate("Xs", "findall(X, member(X, [1,2,3]), Xs)", "mydid");

Seems mostly useful for deterministic queries and should perhaps support only those? If so, we can replace the line

ask: goal,

with

ask: "once((" + goal + "))",

and we don't need populate() to return anything.

@Anniepoo
Copy link
Member

Anniepoo commented May 7, 2016

It seems to me too short a goal.

I've been thinking about this for a while. I'd love to see a logical, reactive end to end framework built on pengines. I've been fiddling around, more with designs than code, but am not happy with what I have.

If you don't know 'angularjs' , (I think react is similar) you might want to look at it just as a model of what might happen.
Angular's big issue is that it's only on the browser. I'd like to make that distinction more transparent.

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

No branches or pull requests

2 participants