1.0.1 • Published 3 years ago

ngx-network v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NgxNetwork

How many times you want from client to upload or download something and you need to be sure his network is fast so with simplest package every and updated continuously with new features NgxNetwork you can do that. let's finish the work 👷‍♂️👷‍♀️

Installation

You can use either the npm command-line tool to install packages.

NPM

npm i ngx-network

Usage ⁉

  • import NgxNetworkModule module
@NgModule({
  imports: [
   /* .... */
   NgxNetworkModule.forRoot(/* (Optional) Config 👇 */)
   /* .... */
  ],
})
  • inject the service NgxNetworkService into your class and using start function to network speed changing as PRO 😳
export class AppComponent implements OnInit {
  constructor(private networkService: NgxNetworkService) {}
  ngOnInit() {
    this.networkService.getSpeed().subscribe((networkSpeedInfo) => {
      /* Do Your Amazing Stuff*/
    });

    /* OR */

     this.networkService.onSpeedChanged().subscribe((networkSpeedInfo) => {
      /* Do Your Amazing Stuff*/
    });
  }

}

Simplest and Easiest 👌💖👏


Configuration

you can change the tool configurations by define these attributes when import NgxNetworkModule

AttributeRequiredTypeDescriptionDefault
url(Optional)stringurl for image or file used for network speed measure you can change to another file from your assets.../1mb.jpg
speedUnit(Optional)Unitsthe unit to measure the network speed'kb/s'
delay(Optional)numberthe unit to measure the network speed100

Assets

500kb

https://raw.githubusercontent.com/mahmoudshahin1111/ngx-network/master/src/assets/mocks/500kb.jpg

1MB

https://raw.githubusercontent.com/mahmoudshahin1111/ngx-network/master/src/assets/mocks/1mb.jpg


API

NgxNetworkService

Properties

FunctionReturnDescription
onSpeedChangedNetworkSpeedInfolisten to speed changing and the request for testing speed will run forever until you cancel it

Functions

FunctionReturnDescription
getSpeedNetworkSpeedInfoget the current network speed

NetworkSpeedInfo | Attribute | Type | Description | | ----------- | ---------: | -------- | | speed | number | url for image or file used for network speed measure you can change to another file from your assets | | unit | Units | the unit to measure the network speed |

Contribution

I welcome you to fork and add more features into it. If you have any bugs or feature request, please create an issue at github repository.

License

MIT