Skip to content

Commit 4397205

Browse files
committed
Usage of plugin added to README
1 parent ab3191e commit 4397205

1 file changed

Lines changed: 58 additions & 5 deletions

File tree

README.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Simple customizeable page loader component with self state manager module for Vu
77
88
## 🎉 version 1 released 🎈
99

10-
## How to use
10+
---
11+
12+
## First steps
1113
### 1. Instalation
1214
Install package in your project with this command
1315

@@ -16,19 +18,33 @@ npm i -S sadrix-vue-page-loader
1618
```
1719

1820
### 2. Import
19-
Import package inside your Vuejs application config file and let you global `Vue` instance use it as a plugin:
21+
Import package inside your Vuejs application config file and let you global **`Vue`** instance use it as a plugin.
22+
23+
>The only **important notice** is this plugin use **`Vuex`** package as state manager and you need to import this package first and config it, then pass you store param as an option property with name of **`store`** (with small `s`) and plugin will automaticaly add needed mutaction, states and actions under namespace of **`pageLoader`**.
2024
2125
``` javascript
2226
import SadrixPageLoader from 'sadrix-page-loader';
2327
import Vue from 'vue';
24-
25-
Vue.use(SadrixPageLoader);
28+
import store from './store/store';
29+
import router from './core/router';
30+
import Page from './layouts/page';
31+
32+
// Let Vue use our plugin
33+
Vue.use(SadrixPageLoader, { store });
34+
35+
// Create app
36+
new Vue({
37+
el: '#app',
38+
router,
39+
store,
40+
render: h => h(Page)
41+
});
2642
```
2743

2844
### 3. Component
2945
Your done! Now easily can use `<page-loader/>` component any where inside your application.
3046

31-
**example: in your `.vue` template file**
47+
* **example: in your `.vue` template file**
3248

3349
``` html
3450
<div>
@@ -68,6 +84,43 @@ Its easy! just pass `:rtl="true"`.
6884
<page-loader :rtl="true"/>
6985
</div>
7086
```
87+
---
88+
## How to use
89+
For faster and easier usage and control on this loader, We add some custom property to `Vue` main module.
90+
You just need to call `showPageLoader(timeout)` when want loader show and how much it take (timeout) to fill window width in `milisecounds` (optionl). default timeout is `10 secounds` or `10000ms`.
91+
And when you want to hide loader easily type `hidePageLoader()`.
92+
93+
* **example: show/hide page loader for and api request**
94+
``` html
95+
<script>
96+
import axios from 'axios';
97+
98+
export default {
99+
methods: {
100+
callApi() {
101+
// for example before making request we want
102+
// to show the page loader and max in 6 secounds timeout
103+
this.$showPageLoader();
104+
105+
// make request
106+
axios.get('https://someurl.com')
107+
// on success
108+
.then(data => {
109+
// here we hide page loader
110+
this.$hidePageLoader();
111+
})
112+
// on error
113+
.catch(error => {
114+
// here we hide page loader
115+
this.$hidePageLoader();
116+
});
117+
}
118+
}
119+
}
120+
</script>
121+
```
122+
123+
---
71124

72125

73126
build your amasing app with a beautiful page loader! 😉

0 commit comments

Comments
 (0)