Tradeshift / tradeshift-ui

Tradeshift UI is a framework-agnostic JavaScript library to help Tradeshift App developers to create cohesive user experiences and to provide reusable UI components.
https://ui.tradeshift.com
Other
33 stars 44 forks source link

Support post-render callback for all UI components #82

Open wiredearp opened 7 years ago

wiredearp commented 7 years ago

If you are injecting custom HTML (such as images) into a UI component (for a demo or a prototype), you are bound to be disappointed when the HTML disappears after an EDBML update.

@vvvts is currently using this technique to simulate a proposed feature in the Table.

To support this kind of hacking, all components should hook into onrender and call a user defined method for this kind of post-render processing. We'll just need to come up with a good name, now that onrender is used by the component internally.

wiredearp commented 7 years ago

Note to self: Also expose onflex with some kind of LifePlugin event.

sheepray commented 6 years ago

thumbs up for onrender callback to make unit test more handy. One example how we do currently.

const handler = {
    onlife: () => {
        if (table.rows().length === 1) {
            expect(table.pager().page).toBe(1);
            expect(table.pager().pages).toBe(4);
            table.life.remove('gui-life-render', handler);
        }
    }
};

table.life.add('gui-life-render', handler);
DocGroth commented 5 years ago

Categorised as Spiritual Issues