本文整理匯總了TypeScript中react-redux-toastr.toastr類的典型用法代碼示例。如果您正苦於以下問題:TypeScript toastr類的具體用法?TypeScript toastr怎麽用?TypeScript toastr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了toastr類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: checkMembershipWorker
// ------------------------------------
// Check membership
// ------------------------------------
function* checkMembershipWorker(action) {
const {Dao1901Members} = contracts
try {
const {memberAddressToCheck} = action.values
let isMember = yield call(Dao1901Members.isMember, memberAddressToCheck)
if (isMember) {
toastr.success('Membership management', `${memberAddressToCheck} is a member`)
} else {
toastr.error('Membership management', `${memberAddressToCheck} is not a member`)
}
yield put({type: 'CHECK_MEMBERSHIP_SUCCEED', values: {isMember}})
} catch (e) {
yield put({type: 'CHECK_MEMBERSHIP_FAILED', error: e.message})
}
}
示例2: test
function test() {
const store = createStore(combineReducers({ toastr: toastrReducer }));
var toastrFactory = React.createFactory(ReduxToastr);
var element = toastrFactory({ timeOut: 1000, newestOnTop: false });
var providerFactory = React.createFactory(Provider);
var root = providerFactory({ store: store }, element);
function callback() { }
toastr.clean();
toastr.confirm("Test", { onOk: callback, onCancel: callback });
toastr.error("Error", "Error message");
toastr.info("Info", "Info test", { timeOut: 1000, removeOnHover: true, onShowComplete: callback });
toastr.success("Test", "Test message", { component: new React.Component({}) });
}
示例3: Promise
return new Promise((resolve, reject) => {
const {Owned} = contracts
const toastrConfirmOptions = {
onOk: () => {
resolve(Owned.changeOwner
.sendTransaction(newOwnerAddress, {from: ownerAddress, gas: 200000})) // todo check gas
},
onCancel: () => console.log('Ownership transfer cancelled')
}
toastr.confirm(`Are you sure that you want to transfer ownership to ${newOwnerAddress}`, toastrConfirmOptions)
})
示例4: toastrManager
export default function toastrManager(nextProps, props) {
let newErrorsLength = nextProps.errors.length
let newTxsLength = nextProps.txs.length
// Checking if new tx and show a toast message
if (newTxsLength > 0 && newTxsLength !== props.txs.length) {
let message, title
switch (nextProps.txs[newTxsLength - 1].event) {
case 'TX_ADD_MEMBER_SUCCEED':
message = `The member ${nextProps.members[nextProps.members.length - 1].memberAddress} has been added successfully`
title = 'Membership management'
break
case 'TX_REVOKE_MEMBER_SUCCEED':
message = `The member has been revoked successfully`
title = 'Membership management'
break
case 'TX_CREATE_PROPOSAL_SUCCEED':
message = 'Your proposal has been successfully submitted'
title = 'Proposal submission'
break
case 'TX_VOTE_SUBMISSION_SUCCEED':
message = 'Your vote has been successfully submitted'
title = 'Voting'
break
case 'TX_TRANSFER_OWNERSHIP_SUCCEED':
message = `The ownership has been transferred to ${nextProps.ownerAddress}`
title = 'Organization management'
break
default:
throw new Error('Unknown event')
}
toastr.success(title, `${message} - Transaction ID: ${nextProps.txs[newTxsLength - 1].tx}`)
}
// Checking if new error and show a toast message
if (newErrorsLength > 0 && newErrorsLength !== props.errors.length) {
let message, title
switch (nextProps.errors[newErrorsLength - 1].event) {
case 'TX_ADD_MEMBER_FAILED':
message = `The member ${nextProps.members[nextProps.members.length - 1].memberAddress} has not been added. Please try later`
title = 'Error'
break
case 'TX_REVOKE_MEMBER_FAILED':
message = `The member has not been revoked successfully. Please try later`
title = 'Error'
break
case 'TX_CREATE_PROPOSAL_FAILED':
message = 'An error occurred. Please try later or contact the support'
title = 'Error'
break
case 'TX_VOTE_SUBMISSION_FAILED':
message = `An error occurred. Please try later or contact the support. ` +
`Hint: Check that the proposal id is valid and that you are registered as member`
title = 'Error'
break
case 'TX_TRANSFER_OWNERSHIP_FAILED':
message = 'You don\'t have the rights to transfer ownership'
title = 'Error'
break
default:
throw new Error('Unknown event')
}
toastr.error(title, message)
}
}
示例5: dispatch
DataSource.students.update(editedStudent).then(updatedStudent => {
dispatch(commonActionCreators.finishTalkingToTheServer());
hashHistory.push('/students');
toastr.success('Student updated');
});