1.1.18 • Published 10 months ago
@equinor/fusion-framework-react-widget v1.1.18
Fusion React App
Package for developing applications that uses the @equinor/fusion-framework
.
Dependencies
Configure
// config.ts
import { AppConfigurator } from '@equinor/fusion-framework-react-app';
const configCallback: AppConfigurator = (configurator) => {
configurator.http.configureClient(
'bar', {
baseUri: 'https://somewhere-test.com',
defaultScopes: ['foo/.default']
}
);
};
// App.tsx
export const App = () => {
const client = useHttpClient('bar');
const [foo, setFoo] = useState('no value');
const onClick = useCallback(() => {
client.fetchAsync('api').then(x => x.json).then(setFoo);
}, [client]);
return <Button onClick={onClick}>{foo}</Button>
}
// index.ts
import { createApp } from '@equinor/fusion-framework-react-app';
export const render = createApp(App, configCallback);
export default render;
Hooks
useModule
import { useModule } from '@equinor/fusion-framework-react-app';
const ShowToken = () => {
const auth = useModule('auth');
const [token, setToken] = useState<string>('');
useEffect(() => {
auth.acquireAccessToken().then(setToken);
}, [auth]);
return <span>{token ?? 'fetching token'}</span>
}
Http
useHttpClient
import { useHttpClient } from '@equinor/fusion-framework-react-app/http';
const App = () => {
const fooClient = useHttpClient('foo');
// using as stream
useEffect(() => {
const sub = client.fetch('api/all').subscribe((x) => {
setFoo(x.json());
});
return () => sub.unsubscribe();
},[fooClient]);
// using as promise
const barClient = useHttpClient('bar');
useCallback(async() => {
const res = await portalClient.fetchAsync('api/bar');
console.log(res.json());
},[barClient]);
}
Feature Flag
!IMPORTANT
@equinor/fusion-framework-module-feature-flag
must be installed to make this module available
Simple
import { enableFeatureFlag } from '@equinor/fusion-framework-react-app/feature-flag';
export const configure: ModuleInitiator = (appConfigurator, args) => {
/** provide a list of features that should be available in the application */
enableFeatureFlag(appConfigurator, [
{
key: MyFeatures.MyFlag,
title: 'this is a flag',
},
{
key: MyFeatures.MyUrlFlag,
title: 'this feature can be toggled by ?my-url-flag=true',
allowUrl: true,
}
]);
}
Custom
export const configure: ModuleInitiator = (appConfigurator, args) => {
appConfigurator.useFeatureFlags(builder => /** see module for building custom config */);
}
see module for more technical information;
1.1.18
10 months ago
1.1.18-next-54618d61fef0bcafa56d37212c9e89b2f3155db0
10 months ago
1.1.18-next-65f4bbf022d22b529abd095acd74ab218499fb8b
10 months ago
1.1.18-next-ad690a9e34895039f4df7dd6d6f505206fa9fa23
10 months ago
1.1.18-next-536392d2277f82421eaeb407d8839c716cb83be0
10 months ago
1.1.18-next-e2f0f5f45ddcf734f0d1c8a7ea2fb5e761f7b8f0
10 months ago
1.1.18-next-43b4cac9210dd754e552b9f32ae229477e5ca643
10 months ago
1.1.18-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8
10 months ago
1.1.9
1 year ago
1.1.8
1 year ago
1.1.12
1 year ago
1.1.11
1 year ago
1.1.10
1 year ago
1.1.16
10 months ago
1.1.15
11 months ago
1.1.14
11 months ago
1.1.13
12 months ago
1.1.17
10 months ago
1.1.18-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4
10 months ago
2.0.0-next-663bed8344cc2ca0111705b05045173328b3104d
10 months ago
1.1.18-next-eafbd16f5fe29e2541a1a35881b265cd027de89e
10 months ago
1.1.7
1 year ago
1.1.6
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.0.1-widget-acdcb9b2
1 year ago
1.1.0
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1-widget-b2daf10f
1 year ago
1.0.1-widget-f4c3a78c
1 year ago
1.0.1-widget-7844194d
1 year ago
1.0.1-widget-80a83af4
1 year ago
1.0.1-widget-c4528777
1 year ago
1.0.1-widget-50a1870b
1 year ago
1.0.1
1 year ago
1.0.1-widget-47330bca
1 year ago
1.0.0
1 year ago