Skip to content
This repository was archived by the owner on Jun 21, 2025. It is now read-only.

2.4.0

Choose a tag to compare

@papablack papablack released this 23 Apr 16:29
· 86 commits to master since this release

DEPENDENCY INJECTION UPDATE

New constructors:

/*
  Minimal import for Service 

    - Default export is FAST DI interface pointing to created singleton service. 
    - Named one returns service class type.
*/
import RoutingService, { RoutingServiceInstance } from '../../services/RoutingService'; 


@RWSView('rws-router')
export class RouterComponent extends RWSViewComponent {    
    static autoLoadFastElement = false;
    private routing: RWSRouter;
    private currentComponent: IRWSViewComponent;

    @observable currentUrl: string;
    @observable childComponents: HTMLElement[] = [];    
    slotEl: HTMLElement = null;

    constructor(@RWSInject(RoutingService) protected routingService: RoutingServiceInstance){
        super();
    }

    connectedCallback() {
        super.connectedCallback();   
           
        this.routing = this.routingService.apply(this);   
                
        if(this.currentUrl){            
            this.handleRoute(this.routing.handleRoute(this.currentUrl));      
        }           
    }
    // (...)
}

Example service

class RoutingService extends TheService {
    private router: Router<any>;
    private routes: IFrontRoutes;

    constructor(@UtilsService private utilsService: UtilsServiceInstance, @ConfigService private config: ConfigServiceInstance){
        super();        
    }    

// (...)
}

export default RoutingService.getSingleton(); // Fast pointer to DI container slot the service instance is in
export { RoutingService as RoutingServiceInstance } // service class type for typing props.

.rws.json

Now we can set env settings for vars from client.setup() / client.start() AND webpack in .rws.json (placed in build command dir)

example config file:

{
  "dev": true,
  "parted": false,
  "partedDirUrlPrefix": "/js",
  "backendUrl": "http://localhost:1337",
  "wsUrl" : "http://localhost:1338",
  "partedPrefix": "jtrainer",
  "copyAssets": {
      "./public/js/" : [
        "./build/",
        "./src/styles/compiled/main.css"
      ]
  }
}

default cfg file: https://github.com/papablack/rws-client/blob/master/cfg/_default.cfg.js