Is it possible to change a variable on input, and that variable is a parameter of a class (OOP code) and automatically changes on input and gets passed to the class?
I am asking because this is the first time I want to use svelte, and I have an entire app of my company written in JavaScript OOP and I want to rewrite it entirely to svelte.
And I wonder if I can copy and paste the old class code and use the bind and other cool stuff from svelte to make it more interesting, and faster and reactive
<script>
let myReactiveVar = "hello";
class myClass {
constructor(variable) {
this.variable = variable;
}
myMethod() {
// some code
}
get getterVar {
// return something
}
}
// here the let variable should always change and passed to the class
// the class is used only for business logic (oop)
let myCreatedClass = new myClass(myReactiveVar)
</script>
// the change happen with input bind.
<input bind:value={myReactiveVar}/>
<p>{myCreatedClass.getterVar}</p>
or should I rewrite the logic with functional programming?