3.0.0 • Published 16 days ago

@edular/modules v3.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
16 days ago

@edular/modules

current npm version

Shared constants and utils for modules handling in Edular project.

How to use the library

yarn add @edular/modules

or

npm install --save @edular/modules

Initialize

Wrap your parent component with EdularModulesProvider

//App.tsx
import { EdularModulesProvider } from '@edular/modules';

// ...
return (
  <EdularModulesProvider>
    <ChildComponent />
  </EdularModulesProvider>
);

Somewhere in the app when you have profile and token ready

import { useEdularModuleContext } from '@edular/modules';

function OtherComponent() {
  const profile = useSelector(getActiveProfileState);
  const {
    initialize, // Initialize modules
    refreshModules, // Use this in case you need to refresh modules
  } = useEdularModuleContext();

  useEffect(() => {
    if (!profile) {
      return;
    }
    initialize({
      profileId: profile.id,
      token: keychain.getTokens().accessToken,
      baseUrl: config.edularApiBaseUrl,
    });
  }, [profile]);

  // In mobile, I would like to refresh module whenever app is bring back to foreground
  useAppState(state => {
    if (state === 'active') {
      refreshModules();
    }
  });
}

Usage

In functional component

import { useEdularModuleContext, Modules } from '@edular/modules';

function SomeComponent() {
  const { isModuleEnable } = useEdularModuleContext();

  return (
    <Component>
      {isModuleEnable(Modules.Admissions) && <AdmissionsComponent />}
    </Component>
  );
}

In class component

import { EdularModulesContext, Modules } from '@edular/modules';

class SomeComponent() {
  static contextType = EdularModulesContext

  render() {
    const { isModuleEnable} = this.context

    return (
      <Component>
        {isModuleEnable(Modules.Admissions) && <AdmissionsComponent />}
      </Component>
    )
  }
}

Modules

The repository contains the modules.ts file that exports Modules object — all available modules. The file is generated based on the modules list from the main Edular database.

Scripts

  • build — building the library artifacts (lib/ directory)
  • build:clean — clean the build directory lib/
  • generate-modules — generate modules.ts with the Modules object exported

How to publish new version

  1. Start the edular-core and run yarn generate-modules to generate new modules.ts.
  2. Commit the change and run npm version major|minor|patch -m "bump %s" to bump new version.
  3. Publish to npm registry by running yarn publish.
  4. Update the version in package.json manually or use npm for that:
npm version <major|minor|patch>
  1. Commit the changes and push them to the remote repository

  2. Publish new version to npm registry

npm publish
3.0.0

16 days ago

2.8.7

16 days ago

2.8.6

1 month ago

2.8.5

2 months ago

2.9.4

2 months ago

2.8.4

2 months ago

2.3.0

9 months ago

2.2.0

10 months ago

2.5.0

7 months ago

2.4.0

7 months ago

2.7.0

7 months ago

2.6.0

7 months ago

2.5.1

7 months ago

2.8.1

6 months ago

2.8.0

7 months ago

2.1.0

10 months ago

2.8.3

6 months ago

2.8.2

6 months ago

2.0.3

12 months ago

2.0.2

12 months ago

2.0.4

12 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago