How to use the lightning/platformResourceLoader.loadScript function in lightning

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Gurenax / sfdx-lwc-fullcalendarjs / force-app / main / default / lwc / fullCalendarJs / fullCalendarJs.js View on Github external
renderedCallback() {

    // Performs this operation only on first render
    if (this.fullCalendarJsInitialised) {
      return;
    }
    this.fullCalendarJsInitialised = true;

    // Executes all loadScript and loadStyle promises
    // and only resolves them once all promises are done
    Promise.all([
      loadScript(this, FullCalendarJS + '/jquery.min.js'),
      loadScript(this, FullCalendarJS + '/moment.min.js'),
      loadScript(this, FullCalendarJS + '/fullcalendar.min.js'),
      loadStyle(this, FullCalendarJS + '/fullcalendar.min.css'),
      // loadStyle(this, FullCalendarJS + '/fullcalendar.print.min.css')
    ])
    .then(() => {
      // Initialise the calendar configuration
      this.initialiseFullCalendarJs();
    })
    .catch(error => {
      // eslint-disable-next-line no-console
      console.error({
        message: 'Error occured on FullCalendarJS',
        error
      });
    })
  }
github samkhan27 / lwc-redux / force-app / main / default / lwc / provider / provider.js View on Github external
secondary,
        } = this;
        
        if (secondary) {
            try {
                await poll(() => (window.reduxStores && window.reduxStores[this.storeName]));
                this.resourceLoaded = true;
                return;
            } catch (ex) {
                console.log(ex);
                return;
            }
        }

        await Promise.all([
            loadScript(this, reduxResourceURL),
            loadScript(this, reduxThunkResourceURL),
            loadScript(this, lodashResourceURL),
        ]);

        const { 
            createStore, 
            applyMiddleware, 
            combineReducers 
        } = window.Redux;

        const ReduxThunk = window.ReduxThunk.default;
        const logger = createLoggerMiddleware(storeName);
        const rootReducer = useCombineReducers ? combineReducers(reducers) : reducers;
        
        let enhancer;
        if (useThunk && useLogger) {
github samkhan27 / lwc-redux / force-app / main / default / lwc / provider / provider.js View on Github external
} = this;
        
        if (secondary) {
            try {
                await poll(() => (window.reduxStores && window.reduxStores[this.storeName]));
                this.resourceLoaded = true;
                return;
            } catch (ex) {
                console.log(ex);
                return;
            }
        }

        await Promise.all([
            loadScript(this, reduxResourceURL),
            loadScript(this, reduxThunkResourceURL),
            loadScript(this, lodashResourceURL),
        ]);

        const { 
            createStore, 
            applyMiddleware, 
            combineReducers 
        } = window.Redux;

        const ReduxThunk = window.ReduxThunk.default;
        const logger = createLoggerMiddleware(storeName);
        const rootReducer = useCombineReducers ? combineReducers(reducers) : reducers;
        
        let enhancer;
        if (useThunk && useLogger) {
            enhancer = applyMiddleware(ReduxThunk, logger)
github samkhan27 / lwc-redux / force-app / main / default / lwc / provider / provider.js View on Github external
if (secondary) {
            try {
                await poll(() => (window.reduxStores && window.reduxStores[this.storeName]));
                this.resourceLoaded = true;
                return;
            } catch (ex) {
                console.log(ex);
                return;
            }
        }

        await Promise.all([
            loadScript(this, reduxResourceURL),
            loadScript(this, reduxThunkResourceURL),
            loadScript(this, lodashResourceURL),
        ]);

        const { 
            createStore, 
            applyMiddleware, 
            combineReducers 
        } = window.Redux;

        const ReduxThunk = window.ReduxThunk.default;
        const logger = createLoggerMiddleware(storeName);
        const rootReducer = useCombineReducers ? combineReducers(reducers) : reducers;
        
        let enhancer;
        if (useThunk && useLogger) {
            enhancer = applyMiddleware(ReduxThunk, logger)
        } else if (useThunk) {
github TheVishnuKumar / lwc-streaming-api / force-app / main / default / lwc / lwc_streaming_api / lwc_streaming_api.js View on Github external
loadCometdScript(){
        if( !this.subscription ){
            Promise.all([
                loadScript(this, cometdStaticResource + '/cometd.js')
            ])
            .then(() => {
                this.loadSessionId();
            })
            .catch(error => {
                let message = error.message || error.body.message;
                this.fireErrorEvent(message);
            });
        }
        else{
            this.fireErrorEvent('Subscription already exists.');
            this.consoleLog('(LWC Streaming API) Error: Subscription already exists.');
        }
    }