Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function for reading window.Fusion property #275

Open
Gustav-Eikaas opened this issue Sep 20, 2022 · 0 comments
Open

Function for reading window.Fusion property #275

Gustav-Eikaas opened this issue Sep 20, 2022 · 0 comments
Assignees
Labels
✨ improvement 🤷 question Further information is requested

Comments

@Gustav-Eikaas
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
When reading the window.Fusion property I should/must ensure the properties im trying to access exists
e.g

if (!window?.Fusion) {
		throw new Error('No fusion framework found, required for fusion bookmarks module to work');
	}
	const fusion = window.Fusion;
	if (!fusion.modules.serviceDiscovery) {
		throw new Error('Service discovery module not configured, required for fusion bookmarks module to work');
	}

	const client = await fusion.modules.serviceDiscovery.createClient('bookmarks');
	return client;

Describe the solution you'd like
Proposed solution: Function on window object called something like window.getFusionInstance(). Which implementes the above checks. Could possibly return an object with further functions that ensures the module you're dotting into also exists. Either by using Proxy class or by getting modules using functions

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
const fusion = window.getFusion();
//Could throw error saying service discovery is not configured/included
fusion.getModule("service_discovery");

@Gustav-Eikaas Gustav-Eikaas added ✨ improvement 🤷 question Further information is requested labels Sep 20, 2022
@odinr odinr self-assigned this Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ improvement 🤷 question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants