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

chore(dependencies): upgrade dependencies #5

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<a name="2.0.0"></a>
# [2.0.0](https://github.com/ngrx/notify/compare/v1.0.0...v2.0.0) (2017-07-22)


### Chores

* **dependencies:** upgrade dependencies ([8592504](https://github.com/ngrx/notify/commit/8592504)), closes [#2](https://github.com/ngrx/notify/issues/2) [#3](https://github.com/ngrx/notify/issues/3)


### BREAKING CHANGES

* **dependencies:** The peer dependencies have been upgraded to be:
* "rxjs": "^5.4.2",
* "@angular/core": "^4.3.0",
* "@ngrx/store": "^2.2.3"



<a name="1.0.0"></a>
# 1.0.0 (2016-06-07)



61 changes: 40 additions & 21 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var path = require('path');
var webpack = require('webpack');

module.exports = function(karma) {
'use strict';
Expand All @@ -18,16 +19,17 @@ module.exports = function(karma) {
'tests.js': ['coverage', 'webpack', 'sourcemap']
},

reporters: ['mocha', 'coverage'],
reporters: ['mocha', 'coverage-istanbul'],

coverageReporter: {
dir: 'coverage/',
subdir: '.',
reporters: [
{ type: 'text-summary' },
{ type: 'json' },
{ type: 'html' }
]
coverageIstanbulReporter: {
dir: path.join(__dirname, 'coverage'),
reports: [
'html',
'lcovonly',
'json',
'clover'
],
fixWebpackSourcePaths: true
},

browsers: ['Chrome'],
Expand All @@ -41,32 +43,49 @@ module.exports = function(karma) {

webpack: {
devtool: 'inline-source-map',
entry: undefined,
resolve: {
root: __dirname,
extensions: ['', '.ts', '.js']
extensions: ['.ts', '.js'],
modules: [
path.join(__dirname),
'node_modules'
]
},
module: {
loaders: [
rules: [
{
test: /\.ts?$/,
exclude: /(node_modules)/,
loader: 'ts-loader?target=es5&module=commonjs'
}
],
postLoaders: [
use: [
{
loader: 'ts-loader?target=es5&module=commonjs'
}
]
},
{
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
test: /\.(js|ts)$/,
enforce: 'post',
include: path.resolve(__dirname, 'lib'),
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/
],
use: [
{
loader: 'istanbul-instrumenter-loader'
}
]
}
]
},
ts: {
configFileName: './spec/tsconfig.json'
}
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
ts: {
configFileName: './spec/tsconfig.json'
}
}
})
]
},

webpackServer: {
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Notify } from './notify';
export { NOTIFY_PROVIDERS, NOTIFY_GLOBAL_OPTIONS } from './ng2';
export { NotifyModule, NOTIFY_GLOBAL_OPTIONS } from './ng2';
export { NotificationInstance, NotificationOptions } from './notification';
90 changes: 51 additions & 39 deletions lib/ng2.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,57 @@
import { OpaqueToken } from '@angular/core';
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';

import { Notify } from './notify';
import { NotificationStatic, NotificationOptions } from './notification';
import { NotificationPermission } from './notification-permission';

declare var Notification: NotificationStatic;

export const NOTIFY_GLOBAL_OPTIONS = new OpaqueToken('[@ngrx/notify] Global Options');
export const NOTIFICATION_STATIC = new OpaqueToken('[@ngrx/notify] Notification Static Constructor');


const NOTIFICATION_STATIC_PROVIDER = {
provide: NOTIFICATION_STATIC,
useValue: Notification
};

const NOTIFICATION_PERMISSION_PROVIDER = {
provide: NotificationPermission,
deps: [ NOTIFICATION_STATIC ],
useFactory(Notification: NotificationStatic) {
return new NotificationPermission(Notification);
declare const window: any;
export declare var Notification: NotificationStatic;

export const NOTIFY_GLOBAL_OPTIONS = new InjectionToken<NotificationOptions>('[@ngrx/notify] Global Options');
export const NOTIFICATION_STATIC = new InjectionToken<NotificationStatic>('[@ngrx/notify] Notification Static Constructor');

export function createNotification(): NotificationStatic {
return window.Notification;
}

export function createNotificationPermission(notification: NotificationStatic): NotificationPermission {
return new NotificationPermission(notification);
}

export function createNotify(notification: NotificationStatic, options: NotificationOptions, permission$: NotificationPermission): Notify {
return new Notify(notification, options, permission$);
}

@NgModule({
})
export class NotifyModule {
static forRoot(options: NotificationOptions = {}): ModuleWithProviders {
return {
ngModule: NotifyModule,
providers: [
{
provide: NOTIFICATION_STATIC,
useFactory: (createNotification)
},
{
provide: NotificationPermission,
deps: [NOTIFICATION_STATIC],
useFactory: (createNotificationPermission)
},
{
provide: NOTIFY_GLOBAL_OPTIONS,
useValue: options
},
{
provide: Notify,
deps: [
NOTIFICATION_STATIC,
NOTIFY_GLOBAL_OPTIONS,
NotificationPermission
],
useFactory: (createNotify)
}
]
};
}
};

const NOTIFY_PROVIDER = {
provide: Notify,
deps: [ NOTIFICATION_STATIC, NOTIFY_GLOBAL_OPTIONS, NotificationPermission ],
useFactory(Notification: NotificationStatic, options: NotificationOptions[], permission$: NotificationPermission) {
return new Notify(Notification, options, permission$);
}
};

const DEFAULT_GLOBAL_OPTIONS_PROVIDER = {
provide: NOTIFY_GLOBAL_OPTIONS,
multi: true,
useValue: {}
};

export const NOTIFY_PROVIDERS: any[] = [
NOTIFICATION_STATIC_PROVIDER,
NOTIFICATION_PERMISSION_PROVIDER,
NOTIFY_PROVIDER,
DEFAULT_GLOBAL_OPTIONS_PROVIDER
];
}
6 changes: 5 additions & 1 deletion lib/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export type NotificationPermissionStatus = 'denied' | 'granted' | 'default';
export enum NotificationPermissionStatus {
DENIED = 'denied',
GRANTED = 'granted',
DEFAULT = 'default'
}

export interface NotificationOptions {
dir?: 'auto' | 'ltr' | 'rtl';
Expand Down
12 changes: 5 additions & 7 deletions lib/notify.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import 'rxjs/add/operator/cache';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/share';
import { Observable } from 'rxjs/Observable';
import { Subscriber } from 'rxjs/Subscriber';

import { NotificationStatic, NotificationOptions, NotificationInstance } from './notification';


export class Notify {
private _permission$: Observable<boolean>;

constructor(
private notificationConstructor: NotificationStatic,
private globalOptions: NotificationOptions[],
private globalOptions: NotificationOptions,
permission$: Observable<boolean>
) {
this._permission$ = permission$.cache();
this._permission$ = permission$.share();
}

requestPermission(): Observable<boolean> {
return this._permission$;
}

private _createNotificationObservable(title: string, _options?: NotificationOptions) {
const options: NotificationOptions = Object.assign({}, ...this.globalOptions, _options);
const options: NotificationOptions = { ...this.globalOptions, ..._options };

return new Observable((subscriber: Subscriber<NotificationInstance>) => {
const notification = new this.notificationConstructor(title, options);
Expand Down
Loading