-
Notifications
You must be signed in to change notification settings - Fork 5
Toast Notifications
Ken Giroux edited this page Sep 13, 2019
·
3 revisions
Issuing Toast Notifications is a particular case of Using Redux in Zimlets.
Use wiretie
to get dispatch
and notify
from context.
import wire from 'wiretie';
import { connect } from 'preact-redux';
import { withText } from 'preact-i18n';
/**
* withText is used to get the message text
*/
@withText({
errorMessage: 'notification-zimlet.errorMessage',
successMessage: 'notification-zimlet.successMessage'
})
/**
* Wiretie is used to mapContextToProps
*/
@wire('store', null, store => ({
dispatch: store.dispatch,
notify: store.zimletRedux.actions.notifications.notify
}))
class NotificationComponent extends Component {
handleError = () => {
const { dispatch, notify, errorMessage } = this.props;
dispatch(
notify({
failure: true,
message: errorMessage
})
);
};
handleSuccess = () => {
const { dispatch, notify, successMessage } = this.props;
dispatch(notify({message: successMessage}));
};
}
- Home
- Client Tool
- Getting Started
- Creating Your Zimlet
- Zimlet Design Patterns
- Advanced