Answer the question
In order to leave comments, you need to log in
Can classes be combined into namespaces in ES6?
I really like the architecture and organization of the Leaflet library. It includes a lot of entities (maps, layers, markers, balloons, vector elements, and so on). But all this sits in a common object, which plays the role of a namespace. Very clear, concise, convenient.
L.Map
L.TileLayer
L.Marker
var a = new MyLib.Dedka();
var b = new MyLib.Babka();
var c = new MyLib.Repka();
Answer the question
In order to leave comments, you need to log in
But all this sits in a common object, which plays the role of a namespace. Very clear, concise, convenient.
import L from 'leaflet';
var m = new L.Map();
// и
import {Map} from 'leaflet';
var m = new Map();
What's stopping you from doing this?
// MyLib.js
export class Dedka {}
export class Repka extends Dedka {}
// клиентский код
import MyLib from './lib/MyLib';
const a = new MyLib.Dedka();
const c = new MyLib.Repka();
import {Dedka, Koshka as Zhoochka} from './lib/MyLib';
not a penny. Sergei Protko is absolutely right, all these pseudo-"namespaces" are solely due to the lack of a normal modular system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question