Giter Club home page Giter Club logo

domino.js's Introduction

👋 Hello!

I'm Alexis Jacomy, aka @jacomyal, a Front-End Engineer specialized in graphical rendering and data visualization.

I'm part of the innovative team at OuestWare, an agency based in Nantes, France. We specialize in developing web applications for data exploration.

As a part of my work at OuestWare, I'm the main developer and maintainer of sigma.js, an open-source library focused on efficiently displaying networks within web pages.

We also develop:

  • Gephi Lite a web-based, lighter version of Gephi, the networks visualization and exploration software;
  • Retina, a web application to share graph visualizations online.

Finally, I sometimes write on 🐘 Mastodon or on 🗒 OuestWare's blog.

Thank you for visiting, and let's connect!

domino.js's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

domino.js's Issues

Dealing with lists in properties

I propose a new feature to deal with a common issue. I often need to deal with properties that are lists of items. For instance I have a list of jobs to display, and I have a property called "jobsList" that is an array. Domino is not much adapted to dealing with this kind of properties. I'll just write here what I would like.

(...to be continued, sorry no more time today)

Callback executed twice

This is a weird bug: When a service is called from inside domino (hacks, success callbacks, etc...), its success callback is executed twice. And the same bug occurs when using setter or events as well.

Here is a test case:

var domInst = new domino({
  hacks: [
    {
      triggers: 'myEvent1',
      method: function() {
        this.request({
          service: 'myService'
        });
      }
    },
    {
      triggers: 'myEvent2',
      method: function() {
        console.log('myEvent2 triggered');
      }
    }
  ],
  services: {
    myService: {
      url: '/myService',
      type: 'GET',
      success: function() {
        this.dispatchEvent('myEvent2');
      }
    }
  }
});

domInst.dispatchEvent('myEvent1');

Here it is. Also, it looks like this bug is directly related to the last commit.


Edit: It is weirder than this, actually. The success callback is executed one, but everything it does is used twice...

Assigning values in scopes

Since there are now "fake" asynchronous methods available in scopes (dispatchEvent(), request(), ...), it might be more natural to use a method like update() or set() to update properties than directly adding them into the current scope. Especially since these properties are not in the scope until the user put them by himself to update their values.

dispatchEvent polymorphism fail

Bonjour

the domino instance method dispatchEvent for multiple events doesn't work as expected - i,e as described in the documentation:

domino.instance.dispatchEvent('event_type_a event_type_b');

Voila the workaround :

domino.instance.dispatchEvent('event_type_a').dispatchEvent('event_type_b');

Wrong warning in _mainLoop

The warning sent when a hack is trying to update a property that has already been updated during the same loop looks wrong (link):

'The property "' + k + '" is not a method nor a property.'

Properties 'toString' methods

It would be great to have the possibility to override a toString method for a property or a custom structure.

This could be useful at least to log updated values, and also for the templating features to come.

Using the "force" flag as a setting (global, instance, property)

In _mainLoop, it is possible to use a "force" flag to force properties to trigger descending events, even if the new value is not different than the old one. And that's great.

Unfortunately, there is currently just no way to use that flag... That would be great to be able to use this flag exactly as the clone flag:

  • Usable the global domino settings
  • Usable from the instance settings
  • Usable via the property definition

More classic asynchronous workflow potentiel

In a project I'm currently working on, I must load dynamically assets from my modules, and it's pretty painful, right now.

These assets cannot be referenced independantly in my domino controler, so since they are all lists, the property "lists" represents them:

  1. In my module constructor, I cannot dispatch event, since the events bindings are not done yet.
  2. Let's say I can dispatch my event (with some dirty setTimeout, for instance). So, I now when some assets are loaded (through the "listsUpdated" event), but I am not sure yet that this is actually the piece I need. Indeed, some other modules created at the same time might have asked for some other assets, right?

So, basically, what I suggest here is that for this kind of cases precisely, I would definitely enjoy to use a more classic, callback-based syntax to communicate from the module...

domino.module inheritance fix

The code domino.module.call(this); should not be necessary: Since the controller will call the child module constructor, it can directly call it on a new domino.module instead of a new empty object.

Of course, if domino.module.call(this); is still there, the module must stay valid.

Provide a public access for instance configuration hash

It might be good to have an access to the instance definition (properties, service, etc...), for example to easily generate forms from the properties. Also, it would be great to allow custom keys in properties / hacks / services / ...

Add custom functions in all scopes of an instance

Sometimes there are some tooling functions that I'd like to be able to call from modules and hacks - but I do not want to put them in the global scope.

Adding a key in domino constructor configuration object to deal with these methods (that might have the read-only scope) would be really useful.

Logs: Give an ID to each events chain

Sometimes, several different events chains can be executed in parallele (when using before in services, for instance). Then, the log can look like:

...
[myDomino] Iteration 1 (main loop)
[myDomino]  -> Events:  ["anEvent"]
[myDomino] Iteration 5 (main loop)
[myDomino]  -> Events:  ["anotherEvent"]
[myDomino] Iteration 6 (main loop)
[myDomino]  -> Events:  ["yetAnotherEvent"]
...

It might be useful to have each chain having an ID displayed, like this:

...
[myDomino] Iteration 1 (chain 2)
[myDomino]  -> Events:  ["anEvent"]
[myDomino] Iteration 5 (chain 1)
[myDomino]  -> Events:  ["anotherEvent"]
[myDomino] Iteration 6 (chain 1)
[myDomino]  -> Events:  ["yetAnotherEvent"]
...

Inconsistency in API - .request()

When manipulating the instance of domino, domInst.request('anyService'), it returns the instance itself, but when calling .request() inside functions (hacks, ...) it does not.

[#6dcdbd] Bug with merged requests and "success" callbacks

Say we have d an instance of domino, with serv1 and serv2 two services.
The following code works well ("Yay!" show up in the console):

d.request('serv1', {
  success: function() {
    console.log('Yay!');
  }
});

But if I call two services in the same call, I have no log, the success callback is never called:

d.request(['serv1', 'serv2'], {
  success: function() {
    console.log('Yay!');
  }
});

Version info

It would be nice to have the current version at the beginning of the development file.

Insert frames between triggers execution

Sometimes, executing some hacks or updating modules can be pretty expensive. It might be nice to be able to insert frames to avoid lag.

If this is done, it is important to deal with priorities as well, and to consider these priorities as dynamic.

[gh-pages] Confusion with "d" to name domino instances

It appears that using d to name the domino instance is confusing since for a lot of people (especially the ones using d3.js), d is a variable name for data.

It seems obvious that dom should be avoided to. So, maybe controller, control or something like this could do the job.

Domino modules templating

An awesome enhancement of the workflow would be to have the possibility to declare domino modules directly from a template.

Two different ideas:

  • A "data binding" approach with Mustaches in HTML (with Handlebars, Hogan, etc...)
  • A "components" approach with a JSON object describing the modules/components (something like Onyx, for instance)

Trigger listeners when just after module creation

When properties already have values and a module is created, it would be great to trigger the listeners. Even better: Triggering the events that have already been fired at least once would be awesome!

Maximum self-loop depth

It would be nice to have a setting to limit the self-loop depth (especially to detect inifinite loop).

[gh-pages] #88484e Missing parameters in doc

For some objects, parameters are listed in the doc, and for some others they are missing:
Properties -> id
Hacks -> triggers, method, ...

Plus it would be cool to have a tree view summary like this:

  • domino
    • properties
      • id
      • label
      • ...
    • hacks
      • id
      • ...
        and so on

Calling "before" with a reference to the XHR object

Some applications use Ajax in a weird way, it could be nice to be able to modify some attributes of the XHR object be launching the call (making the before feature more similar to the jQuery beforeSend).

Dealing with asynchronous actions inside domino hacks

When using an asynchronous action inside a hack, the "pseudo-methods" this.request(), this.dispatchEvent() etc are still existing, but of course are just useless.*

It might be better to throw errors when they are called lately.

Keep references on modules

It would be great to have a reference on modules in the domino instance. This way you don't need to store them outside domino. Maybe you can give an ID to each module so you can find it like so:

domino.instances('foo').modules('bar')

Native hack description

In a hack method, instead of writing something like

this.log('[HACK] Do something');

, I suggest a native "description" key

description: 'Do something'

which would do the same.

"description" could even be a function with event as param

triggers: ['doCoffee', 'doTea'],
description: function(e) {
  return 'I am going to the kitchen to ' + e.type + ' for the breakfast';
}

Error / success mismatch on service (may be linked to 'expect')

I use a service with 'expect' and 'error' functions. I have a backend issue that makes the query fail and the 'expect' clause is not satisfied. My 'error' function correctly triggers, but the log says it is 'successfull'. Here is my service:

{
                id: 'setCurrentWebEntityStatus'
                ,setter: 'statusValidation'
                ,data: function(settings){  return JSON.stringify({ //JSON RPC
                        'method' : HYPHE_API.WEBENTITY.SET_STATUS,
                        'params' : [
                            settings.shortcuts.webEntityId      // web entity id
                            ,settings.shortcuts.status          // new status
                        ],
                    })}
                ,path:'0.result'
                ,url: HYPHE_CONFIG.SERVER_ADDRESS, contentType: 'application/x-www-form-urlencoded', type: 'POST'
                ,expect: function(data){return data[0].code == 'success'}
                ,error: function(data){alert('Oops, an error occurred... \n\nThe server says:\n'+data)}
            }

And here is the log:
[domino] Calling service "setCurrentWebEntityStatus". domino.js:1527
[domino] Service "setCurrentWebEntityStatus" successfull.

More explicit error messages

Currently when I get a type error, it looks like this:

Uncaught Error: [domino] Property "accounts": Type not valid

I would greatly appreciate something like:

expected: "?(array)" was "?(object)"

Or even the wrapped object like:

Uncaught Error: [domino] Property "accounts": Type not valid (expected: "?(array)" was "?(object)") ▶Object {blabla:...}

Structure error message

When you declare a new structure, if it embeds a structure that doesn't exist, you got the message: [domino.global] A structure requires a valid "structure" property describing the structure. It can be a valid structure or a function that test if an object matches the structure.
The stack trace gives you the line of the structure declaration, but it could be useful to know the key and structure involved.

e.g.:

domino.struct.add({
  id: 'jacomyal',
  struct: {
    cruiseMode: 'unknownStruct'
  }
});

In this case, you'd like to know that the key which causes error is cruiseModeand the struct is 'unknownStruct', especially if you've got several complex structs.

Add global/local hooks to catch services responses

Would be nice to make it possible to catch services for one instance or globally. Here is an example (with d a domino instance):

d.addAjaxHook('rpc', function(data) {
  if ((data || {}).result !== 'Ok') {
    this.warn('Unvalid response.');
    return false;
  } else
    return true;
});

Then, when a service returns a data object where data.result !== 'Ok', the related error callback will be triggered instead of the success callback, with the error message 'rpc'.

A "help()" method based on "descriptions"

Following a discussion we had here, it would be nice to be able to document hacks, properties, services, etc... such as it is possible to access these information from the console, through a method domInstance.help().

So the method could be used like this, for instance:

  • domInstance.help('properties/myProperty')
  • domInstance.help('hacks') or domInstance.help('services')
  • domInstance.help('full')

Uncaught error when "expect" callback fails

I am working with RPC services, so I am using the expect methods. And when the expect fails, the error callback is supposed to be triggered.

Instead, I have the following uncaught error:
Uncaught TypeError: Object #<Object> has no method 'xhr'

I think it comes from here.

An "includes" flag to facilitate some structure uses

I would like to declare custom structures, such as the data has to include some typed values associated to specified keys, but it can contain some other keys.

Here is an example of how I'd like to use that:

// Structure declaration:
domino.struct.add({
  id: 'myStruct',
  includes: true, // indicates that other keys can be used
  struct: {
    myKey: 'string'
  }
});

// Some tests:
domino.struct.check('myStruct', {
  myKey: 'myValue',
  anotherKey: {
    containing: 'anything'
  }
}); // would return true
domino.struct.check('myStruct', {
  myKey: 42
}); // would return false

Request: a helper to call a service on event

A module cannot call a service. When I have nothing special to do but I to make a request from a module, I declare a hack, and the module calls the hack, and the hack makes the request. This hack is trivial, like:

{triggers: ['requestMyService']
,method: function(e){
this.request('myService', e.data)
}

So I suggest a helper in the service, so that I could declare it like that:
{
id: 'myService'
,triggers: ['requestMyService']
...
}

Add example of post request in the documentation

It would be useful. Something like :

{                                                                                                                                                                                                                           
  id : 'save',
  type : 'post',
  url : '/uri',
  contentType : 'application/json',
  dataType : 'json',
  data : function() {
    var data = {                                                                                   
      foo : "bar",
    };
    return JSON.stringify(data);
  },
},

[request] 'after' function in services

There is a 'before' function. There could be an 'after' function, triggered however it is a success or a fail.

I would typically need it when I have to dispatch an event related to the fact that the query has been executed (however it succeeds or fails), like decrementing the count of pending queries. The 'before' function was very useful to increment this count.

Merging shortcuts and properties in configuration

Shortcuts are often used as "dynamic properties". So, when properties are organized in different groups in the code (like "data", "interface", etc...), it is weird to have to group the shortcuts again, further in the configuration.

Since shortcuts are kind of properties, it might be nice to be able to declare them at the same place (in the "properties" array).

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.