function chain

优质
小牛编辑
126浏览
2023-12-01

Method chaining is a common pattern in Javascript. Gio's API also provides method chaining in which
could make your code cleaner and more readable. The example below shows how method chaining in Gio.js
works. (You can click the Live Demo, and see its source code how this work)



Without method chaining:

controller.setSurfaceColor( "#00FF00" );
controller.setSelectedColor( "#FF0000" );
controller.disableUnmentioned( true );

With method chaining:

controller.setSurfaceColor( "#00FF00" )
        .setSelectedColor( "#FF0000" )
        .disableUnmentioned( true );