How to use the piral-core.createInstance function in piral-core

To help you get started, we’ve selected a few piral-core 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 smapiot / piral / packages / piral-sample / src / index.tsx View on Github external
return (
    <div>
      
      <div>
        <h1>Sample Portal ({layout})</h1>
        
        <menu>
      </menu></div>
      <div>{children}</div>
      <div>For more information or the source code check out our GitHub repository.</div>
    </div>
  );
};

const Portal = createInstance({
  availableModules: modules,
  requestModules() {
    // return fetch('http://localhost:9000/api/pilet')
    //   .then(res =&gt; res.json())
    //   .then(res =&gt; res.items);
    return new Promise(resolve =&gt; setTimeout(() =&gt; resolve([]), 1000));
  },
  Loader,
  routes: {
    '/sitemap': Sitemap,
  },
});

const App: React.SFC = () =&gt; {content =&gt; {content}};

render(, document.querySelector('#app'));
github smapiot / piral / src / samples / sample-piral-core / src / index.tsx View on Github external
return (
    <div>
      
      <div>
        <h1>Sample Portal ({layout})</h1>
        
        <menu>
      </menu></div>
      <div>{children}</div>
      <div>For more information or the source code check out our GitHub repository.</div>
    </div>
  );
};

const instance = createInstance({
  availablePilets,
  extendApi: [
    createMenuApi(),
    createNotificationsApi(),
    createContainersApi(),
    createDashboardApi(),
    createFeedsApi(),
    createFormsApi(),
    createSearchApi(),
  ],
  requestPilets() {
    // return fetch('http://localhost:9000/api/pilet')
    //   .then(res =&gt; res.json())
    //   .then(res =&gt; res.items);
    return new Promise(resolve =&gt; setTimeout(() =&gt; resolve([]), 1000));
  },
github smapiot / piral / src / packages / piral / src / api.ts View on Github external
export function createPiral(config: PiralConfiguration = {}, settings?: PiralExtSettings) {
  return createInstance({
    ...config,
    extendApi: extendPiralApi(settings, config.extendApi),
  });
}
github smapiot / piral / packages / piral / src / render.tsx View on Github external
export function renderInstance(options: PiralOptions = {}) {
  const { routes = {}, selector = '#app', gateway, translations, components } = options;
  const origin = getGateway(gateway);
  const client = setupGqlClient({
    url: origin,
  });

  const Piral = createInstance({
    availableModules: getAvailableModules(),
    requestModules() {
      return fetch(`${origin}/api/v1/pilet`)
        .then(res =&gt; res.json())
        .then(res =&gt; res.items);
    },
    components,
    Loader,
    Dashboard,
    ErrorInfo,
    extendApi(api: PiralCoreApi): PiletApi {
      return {
        ...api,
        ...createFetchApi({
          base: origin,
        }),
github smapiot / piral / src / samples / sample-cross-fx / src / index.tsx View on Github external
);
};

const DashboardContainer: React.FC = ({ children }) =&gt; <div>{children}</div>;

const Layout: React.FC = ({ children }) =&gt; (
  <div>
    <div>
      <h1>Cross Framework Sample</h1>
    </div>
    <div>{children}</div>
    <div>For more information or the source code check out our GitHub repository.</div>
  </div>
);

const instance = createInstance({
  availablePilets,
  extendApi: [
    createVueApi(),
    createNgApi(),
    createNgjsApi(),
    createHyperappApi(),
    createInfernoApi(),
    createPreactApi(),
    createLitElApi(),
    createMithrilApi(),
    createAureliaApi(),
    createRiotApi(),
    createDashboardApi(),
  ],
  requestPilets() {
    return Promise.resolve([]);