-
Notifications
You must be signed in to change notification settings - Fork 13
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
How to use repluggable for creating plugins #152
Comments
Hi With a Repluggable package you can extend other Repluggable packages by contributing things (components/objects/functions/...) via their APIs // ContactsAPI.tsx
export interface ContactsAPI {/*...*/}
export const ContactsAPI: SlotKey<ContactsAPI>
interface ContactsExtensionItem {/*...*/}
const contactsExtensionsKey: SlotKey<ContactsExtensionItem> = {
name: 'contacts-extensions'
}
const ContactListPure: ReactComponent<ContactListProps> = ({extensions}) => <div>{/*...*/}<div/>
const createContactsListComponent = (boundShell: Shell) => connectWithShell(
shell => ({
extensions: shell.getSlot(contactsExtensionsKey).getItems()
}),
() => ({}),
boundShell
)(ContactListPure)
export const createContactsAPI = (shell: Shell): ContactsAPI => {
const contactsExtensions = shell.declareSlot(contactsExtensionsKey)
return {
contributeContactExtension(contributingShell: Shell, extension: ContactsExtensionItem) {
contactsExtensions.contribute(contributingShell, extension)
},
ContectsList: createContactsListComponent(shell)
}
}
// ContactsPackage.tsx
export const contactsPackage: EntryPoint[] = [{
//...
attach(shell) { shell.contributeAPI(ContactsAPI, () => createContactsAPI(shell)) },
extend(shell) {
const { ContactsList } = shell.getAPI(ContactsAPI)
shell.getAPI(MyWorkspace).contributeComponent(<ContactsList />)
}
}]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there
Suppose there is react app. And suppose there are some React feature components, let's say ContactsList, EditContacts, AddContacts. This components must be plugginable. Like how users control and add plugins in WordPress. How this functionality can be implemented with repluggable package?
The text was updated successfully, but these errors were encountered: