Skip to content

Commit

Permalink
feat: remove the DragAndDropModule.forRoot method
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `DragAndDropModule.forRoot` method was removed. To migrate just import the
`DragAndDropModule` module directly
  • Loading branch information
mattlewis92 committed Jun 10, 2018
1 parent cf1bc61 commit 5ae52a7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ https://mattlewis92.github.io/angular-draggable-droppable/demo/

## Table of contents

* [About](#about)
* [Installation](#installation)
* [Documentation](#documentation)
* [Development](#development)
* [License](#licence)
- [About](#about)
- [Installation](#installation)
- [Documentation](#documentation)
- [Development](#development)
- [License](#licence)

## About

Expand All @@ -40,7 +40,7 @@ import { DragAndDropModule } from 'angular-draggable-droppable';

@NgModule({
declarations: [DemoApp],
imports: [DragAndDropModule.forRoot()],
imports: [DragAndDropModule],
bootstrap: [DemoApp]
})
class DemoModule {}
Expand Down Expand Up @@ -77,8 +77,8 @@ https://mattlewis92.github.io/angular-draggable-droppable/docs/

### Prepare your environment

* Install [Node.js](http://nodejs.org/) and NPM (should come with)
* Install local dev dependencies: `npm install` while current directory is this repo
- Install [Node.js](http://nodejs.org/) and NPM (should come with)
- Install local dev dependencies: `npm install` while current directory is this repo

### Development server

Expand Down
2 changes: 1 addition & 1 deletion demo/demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DemoComponent } from './demo.component';

@NgModule({
declarations: [DemoComponent],
imports: [BrowserModule, DragAndDropModule.forRoot()],
imports: [BrowserModule, DragAndDropModule],
bootstrap: [DemoComponent]
})
export class DemoModule {}
12 changes: 2 additions & 10 deletions src/drag-and-drop.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { NgModule } from '@angular/core';
import { DraggableDirective } from './draggable.directive';
import { DroppableDirective } from './droppable.directive';
import { DraggableHelper } from './draggable-helper.provider';

@NgModule({
declarations: [DraggableDirective, DroppableDirective],
exports: [DraggableDirective, DroppableDirective]
})
export class DragAndDropModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: DragAndDropModule,
providers: [DraggableHelper]
};
}
}
export class DragAndDropModule {}
4 changes: 4 additions & 0 deletions src/draggable-helper.provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Subject } from 'rxjs';
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class DraggableHelper {
currentDrag: Subject<any> = new Subject();
}
2 changes: 1 addition & 1 deletion test/draggable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('draggable directive', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [DragAndDropModule.forRoot()],
imports: [DragAndDropModule],
declarations: [TestComponent]
});
});
Expand Down
3 changes: 1 addition & 2 deletions test/droppable.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as sinon from 'sinon';
import { triggerDomEvent } from './util';
import { DragAndDropModule } from '../src/index';
import { DraggableDirective } from '../src/draggable.directive';
import { DroppableDirective } from '../src/droppable.directive';

describe('droppable directive', () => {
@Component({
Expand Down Expand Up @@ -55,7 +54,7 @@ describe('droppable directive', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [DragAndDropModule.forRoot()],
imports: [DragAndDropModule],
declarations: [TestComponent]
});
});
Expand Down

0 comments on commit 5ae52a7

Please sign in to comment.