Task Description
Set up an abstract class for the runtime which would define the methods and the APIs for runtime in TPF learning section's tutorials.
In the context of TPF, a runtime should have the following behaviour:
Should accept code/command and a callback function which expects results as a string
Should run code/command in the implemented runtime without blocking.
Should call the callback function when the result is obtained from the runtime and should pass the result as an argument to the callback function.
Acceptance criteria for task
[ ] Check that the implementations of the class have a public method named runCode
Additional context
Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.
class PFEditorAbstractClass {
constructor() {
if (this.constructor === PFEditorAbstractClass) {
throw new TypeError('Abstract class "PFEditorAbstractClass" cannot be instantiated directly.');
}
//abstract method for mounting an Editor into a DOM Elemement must be implemented
if(!typeof this.mountEditorToDOMElement === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
if (this.content === undefined) {
throw new TypeError('Classes implementing PFEditorAbstractClass must have the content as an attribute')
}
//abstract method for storing one or more variables in local storage must be implemented
if(!this.saveContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}]
//abstract method for retrieving one or more variables from local storage must be implemented
if(!typeof this. this.getContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for closing the Editor after necessary cleanup operations must be implemented
if(!typeof this.closeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for minimizing the Editor after necessary saving operations must be implemented
if(!typeof this.minimizeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
}
}
Task Description Set up an abstract class for the runtime which would define the methods and the APIs for runtime in TPF learning section's tutorials. In the context of TPF, a runtime should have the following behaviour:
Acceptance criteria for task
runCode
Additional context Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.