Running backend typescript.ts at theia start #1395
Replies: 12 comments
-
| 
         Posted by: on 10/5/2023, 2:39:20 PM @Nandish thank you for the discussion, I believe your class should implement   | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/5/2023, 4:01:35 PM @vince-fugnitto thanks a lot, I will try that.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/24/2023, 2:19:48 PM @vince-fugnitto thanks for your tip, I did follow this, However I end up with error, failed to start frontend aplication, cannot find module http, Could you please let me know, where I could be going wrong, this is pretty basic, I should be able to run some background tasks at theia start.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Mark Sujew on 10/24/2023, 10:52:15 PM 
 
  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/25/2023, 9:47:02 AM Basically I just created a widget extension with yo generator, and added a file named BackendService.ts to the extension folder, I wanted to initialize few stuffs before theia is started or even before my widget is opened. Adding BackendService.ts to the extension folder was a suggestion which I found on google. Kind Regards  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/25/2023, 10:08:46 AM Idea was to have a model initialized  in this BackendService class, and then the widget front end just reacts to change in the model. I was successful to communicate the changes on model  to widget using theia events. I just wanted the view not to have any knowledge of the model at all, hence wanted to create the model in backend service file. Kind Regards  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Mark Sujew on 10/25/2023, 11:39:13 AM Ok, that makes sense, but why bind it in the frontend module? The frontend module runs in the browser and has no access to the backend system (on a pure js level - it can communicate via JSON-RPC). You’re probably looking for something like this documentation.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/25/2023, 2:32:41 PM @msujew , thanks for the tip, I shall look at the documentation and try again. Kind Regards  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/30/2023, 11:55:17 AM @vince-fugnitto @msujew , is it possible to share some example snippets here, it may seem very simple but I am getting little bit confused. I have my widget extension, which has various react components to display the data, backend class hosting the model. I need to communicate the changes on my model to the widget xtension.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Mark Sujew on 10/31/2023, 2:49:52 PM @Nandish The backend module is supposed to go in the   | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 10/31/2023, 4:32:43 PM @msujew thanks, I shall look at it.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Posted by: Nandish on 11/6/2023, 6:04:21 PM @msujew thanks a lot for the help, I could move forward, I believe I have almost achieved what I needed, but stuck with small error. @Injectable() Basically backend calls this function updateView and this function informs view model to update data which will finally be reflected on my view. The moment I try to access the view_model through constructor parameter I get a error, too much recursion. I assumed this would allow my viewmodel to have only one instance which I can access in both widget.tsx and in frontend-module.ts  | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted by: Nandish on 10/5/2023, 2:13:17 PM
Hi Team,
I have a widget extension, generated using yo generator, under this extension file I added backend.ts, I want to just check if I can run the background tasks in this file at the start (either when the widget is created or when theia is started, it would be great if I could configure that as well). Backend.ts file has the following code.
import { injectable } from ‘inversify’;
@Injectable()
export class BackendService {
constructor() {
console.log("###########################################################");
console.log(“Back end logic”);
console.log("############################################################");
}
}
export default BackendService;
in frontend module.ts under container module, I do add the following line
bind(BackendService).toSelf().inSingletonScope();
How ever when I start the theia or my widget I do not end up in the constructor of my BackendService, in fact, I do not hit the constructor of BackendService at any point of time, could you please let me know what am I missing here?
Kind Regards
Nandish
Beta Was this translation helpful? Give feedback.
All reactions