piral-notifications
Advanced tools
Comparing version 0.10.0-pre.837 to 0.10.0-pre.838
@@ -1,5 +0,4 @@ | ||
import { Atom } from '@dbeining/react-atom'; | ||
import { GlobalState } from 'piral-core'; | ||
import { GlobalStateContext } from 'piral-core'; | ||
import { OpenNotification } from './types'; | ||
export declare function openNotification(ctx: Atom<GlobalState>, dialog: OpenNotification): void; | ||
export declare function closeNotification(ctx: Atom<GlobalState>, dialog: OpenNotification): void; | ||
export declare function openNotification(ctx: GlobalStateContext, dialog: OpenNotification): void; | ||
export declare function closeNotification(ctx: GlobalStateContext, dialog: OpenNotification): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_atom_1 = require("@dbeining/react-atom"); | ||
const piral_core_1 = require("piral-core"); | ||
function openNotification(ctx, dialog) { | ||
react_atom_1.swap(ctx, state => (Object.assign(Object.assign({}, state), { notifications: piral_core_1.prependItem(state.notifications, dialog) }))); | ||
ctx.dispatch(state => (Object.assign(Object.assign({}, state), { notifications: piral_core_1.prependItem(state.notifications, dialog) }))); | ||
} | ||
exports.openNotification = openNotification; | ||
function closeNotification(ctx, dialog) { | ||
react_atom_1.swap(ctx, state => (Object.assign(Object.assign({}, state), { notifications: piral_core_1.excludeItem(state.notifications, dialog) }))); | ||
ctx.dispatch(state => (Object.assign(Object.assign({}, state), { notifications: piral_core_1.excludeItem(state.notifications, dialog) }))); | ||
} | ||
exports.closeNotification = closeNotification; | ||
//# sourceMappingURL=actions.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const actions = require("./actions"); | ||
const react_atom_1 = require("@dbeining/react-atom"); | ||
const react_1 = require("react"); | ||
@@ -49,3 +48,3 @@ const piral_core_1 = require("piral-core"); | ||
context.defineActions(actions); | ||
react_atom_1.swap(context.state, state => (Object.assign(Object.assign({}, state), { components: Object.assign(Object.assign({}, state.components), { NotificationsHost: default_1.DefaultHost, NotificationsToast: default_1.DefaultToast }), notifications: getNotifications(context, messages, defaultOptions) }))); | ||
context.dispatch(state => (Object.assign(Object.assign({}, state), { components: Object.assign(Object.assign({}, state.components), { NotificationsHost: default_1.DefaultHost, NotificationsToast: default_1.DefaultToast }), notifications: getNotifications(context, messages, defaultOptions) }))); | ||
return api => ({ | ||
@@ -52,0 +51,0 @@ showNotification(content, customOptions) { |
{ | ||
"name": "piral-notifications", | ||
"version": "0.10.0-pre.837", | ||
"version": "0.10.0-pre.838", | ||
"description": "Plugin for triggering notifications in Piral.", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "^0.10.0-pre.837" | ||
"piral-core": "^0.10.0-pre.838" | ||
}, | ||
@@ -47,3 +47,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "5e8fd9a6f76c1505c459b18a5a06fcbeaa77f1a8" | ||
"gitHead": "5d2f55dafff3ceb751877958c5691dfbf995ae84" | ||
} |
import { Atom, deref } from '@dbeining/react-atom'; | ||
import { openNotification, closeNotification } from './actions'; | ||
import { createActions, createListener } from 'piral-core'; | ||
@@ -10,3 +11,4 @@ describe('Notifications Actions Module', () => { | ||
}); | ||
openNotification(state, 'a'); | ||
const ctx = createActions(state, createListener({})); | ||
openNotification(ctx, 'a'); | ||
expect(deref(state)).toEqual({ | ||
@@ -23,3 +25,4 @@ foo: 5, | ||
}); | ||
closeNotification(state, 'b'); | ||
const ctx = createActions(state, createListener({})); | ||
closeNotification(ctx, 'b'); | ||
expect(deref(state)).toEqual({ | ||
@@ -26,0 +29,0 @@ foo: 5, |
@@ -1,7 +0,6 @@ | ||
import { swap, Atom } from '@dbeining/react-atom'; | ||
import { GlobalState, prependItem, excludeItem } from 'piral-core'; | ||
import { prependItem, excludeItem, GlobalStateContext } from 'piral-core'; | ||
import { OpenNotification } from './types'; | ||
export function openNotification(ctx: Atom<GlobalState>, dialog: OpenNotification) { | ||
swap(ctx, state => ({ | ||
export function openNotification(ctx: GlobalStateContext, dialog: OpenNotification) { | ||
ctx.dispatch(state => ({ | ||
...state, | ||
@@ -12,4 +11,4 @@ notifications: prependItem(state.notifications, dialog), | ||
export function closeNotification(ctx: Atom<GlobalState>, dialog: OpenNotification) { | ||
swap(ctx, state => ({ | ||
export function closeNotification(ctx: GlobalStateContext, dialog: OpenNotification) { | ||
ctx.dispatch(state => ({ | ||
...state, | ||
@@ -16,0 +15,0 @@ notifications: excludeItem(state.notifications, dialog), |
@@ -1,5 +0,6 @@ | ||
import { Atom } from '@dbeining/react-atom'; | ||
import { Atom, swap } from '@dbeining/react-atom'; | ||
import { createNotificationsApi } from './create'; | ||
function createMockContainer() { | ||
const state = Atom.of({}); | ||
return { | ||
@@ -11,3 +12,6 @@ context: { | ||
defineActions() {}, | ||
state: Atom.of({}), | ||
state, | ||
dispatch(update) { | ||
swap(state, update); | ||
}, | ||
} as any, | ||
@@ -14,0 +18,0 @@ api: {} as any, |
import * as actions from './actions'; | ||
import { swap } from '@dbeining/react-atom'; | ||
import { ComponentType, isValidElement, ReactElement } from 'react'; | ||
@@ -106,3 +105,3 @@ import { Extend, GlobalStateContext, withApi, defaultRender } from 'piral-core'; | ||
swap(context.state, state => ({ | ||
context.dispatch(state => ({ | ||
...state, | ||
@@ -109,0 +108,0 @@ components: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
563
29644