O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The DirList module

What are our requirements for the DirList view? It renders the list of directories in the current path. When a user selects a directory from the list, it changes the current path. Subsequently, it updates the list to match the content of the new location:

./js/View/DirList.js

class DirListView {    constructor( boundingEl, dirService ){     this.el = boundingEl;     this.dir = dirService;     // Subscribe on DirService updates     dirService.on( "update", () => this.update( dirService.getDirList() ) );   }     onOpenDir( e ){     e.preventDefault();     this.dir.setDir( e.target.dataset.file );   }      update( collection ) {     this.el.innerHTML = "";     collection.forEach(( fInfo ) => {       this.el.insertAdjacentHTML( "beforeend",  `<li class="dir-list__li" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required