1

I have done this in JAVA some time ago, I had some classes:

-defaultprinter.java
-hpprinter.java
-epsonprinter.java
...

the defaultprinter.java class has a method that can be different on each printer

public void serial() {
  get-serial-depending-on-brand-method()
}

then I have a method that will select what printer to select

if(brand.equals("hp"){
  printer = new hpprinter()
} ...

How can I do this with Javascript? I want to have every printer splited in separated files

-defaultprinter.js
-hpprinter.js
-epsonprinter.js
...

How can I have the common and overridable method

const serial = () => {
  get-serial-depending-on-brand-method()
}

And how can I select the printer that I want?

if(brand == "hp") {
  printer = ??????
} ...

Thanks for the help :D

1 Answer 1

1

First you need modules, either commons js style or es6 modules style.

After that, you can define regular javascript classes and do the subclassing thing.

--

If you doing electron for the first time but have some modern web development background, take a look at the electron-webpack project. It demands some default structure, but it worths the effort to get aligned with it.

here goes a little example!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.