Skip to content

Commit

Permalink
remove redundant fetchOption prop
Browse files Browse the repository at this point in the history
  • Loading branch information
enkot committed Jan 21, 2021
1 parent 0c120e8 commit 0a8a738
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 36 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -111,7 +111,9 @@ Using component's method:
export default {
methods: {
getCharacter() {
return fetch('https://rickandmortyapi.com/api/character/1')
return fetch('https://rickandmortyapi.com/api/character/1').then(res =>
res.json()
)
}
}
}
Expand Down Expand Up @@ -149,15 +151,14 @@ All of these props could be passed to global config as well as directly to compo

| Name | Description | Type |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| `action` | Url string, method or promise object | `String` `Function` `Promise` |
| `action` | Url string, method or promise for default action handler. Or anything else that could be passed to custom `actionHandler` | `any` |
| `lazy` | Enables lazy loading which uses Intersection Observer API under the hood. Defaults to `true` | `Boolean` |
| `delay` | Delay in ms to wait before displaying the pending slot. Disabled by default, if passed `true` - defaults to `200`. If disabled - pending slot will be rendered in SSR | `Boolean` `Number` |
| `margin` | `rootMargin` option for IntersectionObserver class. Defaults to `0px`. See [docs](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Intersection_observer_options) | `String` |
| `threshold` | `threshold` option for IntersectionObserver class. Defaults to `0`. See [docs](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Intersection_observer_options) | `String` |
| `height` | Height of an element that is shown before pending slot. Defaults to `0px` | `String` |
| `watch` | Reactive value or watch function to watch changes and rerun action | `Number` `String` `Array` `Object` `Function` |
| `fetchOptions` | Options for `fetch` function | `Number` |
| `actionHandler` | Custom action handler. F.e. to use `axios` or `apollo` | `Number` |
| `actionHandler` | Custom action handler. F.e. to use custom `fetch`, `axios` or `apollo`. Gets action prop as argument | `Function` |

### slots

Expand Down
13 changes: 3 additions & 10 deletions dist/index.js
@@ -1,4 +1,4 @@
/* vue-lazily v1.0.2 | (c) Taras Batenkov and contributors | https://github.com/enkot/vue-lazily/blob/master/LICENSE */
/* vue-lazily v1.1.3 | (c) Taras Batenkov and contributors | https://github.com/enkot/vue-lazily/blob/master/LICENSE */
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });
Expand All @@ -13,7 +13,7 @@ var isVue3 = !!Vue.h;
var Lazily = ( obj = {
props: {
action: {
type: [String, Function, Promise],
type: [String, Function, Promise, Object],
required: false
},
lazy: {
Expand All @@ -39,10 +39,6 @@ var Lazily = ( obj = {
watch: {
type: [Number, String, Array, Object, Function]
},
fetchOptions: {
type: Object,
default: function () {}
},
actionHandler: {
type: Function
}
Expand Down Expand Up @@ -111,10 +107,7 @@ var Lazily = ( obj = {
getData: function getData(action) {
switch (typeof action) {
case 'string':
return fetch(
action,
Object.assign({}, this.fetchOptions)
).then(function (data) { return data.json(); })
return fetch(action).then(function (data) { return data.json(); })
case 'function':
return action()
default:
Expand Down
6 changes: 3 additions & 3 deletions docs/200.html
@@ -1,9 +1,9 @@
<!doctype html>
<html>
<head>
<title>VueAwaited</title><meta data-n-head="1" charset="utf-8"><meta data-n-head="1" name="viewport" content="width=device-width,initial-scale=1"><meta data-n-head="1" data-hid="description" name="description" content=""><link data-n-head="1" rel="icon" type="image/x-icon" href="/favicon.ico"><base href="/vue-lazily/"><link rel="preload" href="/vue-lazily/_nuxt/27eb9e4.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/5c69d6b.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/c3231a7.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/ffa1d89.js" as="script">
<title>VueAwaited</title><meta data-n-head="1" charset="utf-8"><meta data-n-head="1" name="viewport" content="width=device-width,initial-scale=1"><meta data-n-head="1" data-hid="description" name="description" content=""><link data-n-head="1" rel="icon" type="image/x-icon" href="/favicon.ico"><base href="/vue-lazily/"><link rel="preload" href="/vue-lazily/_nuxt/1f72591.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/5c69d6b.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/b18b62c.js" as="script"><link rel="preload" href="/vue-lazily/_nuxt/ffa1d89.js" as="script">
</head>
<body>
<div id="__nuxt"><style>#nuxt-loading{background:#fff;visibility:hidden;opacity:0;position:absolute;left:0;right:0;top:0;bottom:0;display:flex;justify-content:center;align-items:center;flex-direction:column;animation:nuxtLoadingIn 10s ease;-webkit-animation:nuxtLoadingIn 10s ease;animation-fill-mode:forwards;overflow:hidden}@keyframes nuxtLoadingIn{0%{visibility:hidden;opacity:0}20%{visibility:visible;opacity:0}100%{visibility:visible;opacity:1}}@-webkit-keyframes nuxtLoadingIn{0%{visibility:hidden;opacity:0}20%{visibility:visible;opacity:0}100%{visibility:visible;opacity:1}}#nuxt-loading>div,#nuxt-loading>div:after{border-radius:50%;width:5rem;height:5rem}#nuxt-loading>div{font-size:10px;position:relative;text-indent:-9999em;border:.5rem solid #f5f5f5;border-left:.5rem solid #000;-webkit-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0);-webkit-animation:nuxtLoading 1.1s infinite linear;animation:nuxtLoading 1.1s infinite linear}#nuxt-loading.error>div{border-left:.5rem solid #ff4500;animation-duration:5s}@-webkit-keyframes nuxtLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes nuxtLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}</style><script>window.addEventListener("error",function(){var e=document.getElementById("nuxt-loading");e&&(e.className+=" error")})</script><div id="nuxt-loading" aria-live="polite" role="status"><div>Loading...</div></div></div><script>window.__NUXT__={config:{},staticAssetsBase:"/vue-lazily/_nuxt/static/1611062995"}</script>
<script src="/vue-lazily/_nuxt/27eb9e4.js"></script><script src="/vue-lazily/_nuxt/5c69d6b.js"></script><script src="/vue-lazily/_nuxt/c3231a7.js"></script><script src="/vue-lazily/_nuxt/ffa1d89.js"></script></body>
<div id="__nuxt"><style>#nuxt-loading{background:#fff;visibility:hidden;opacity:0;position:absolute;left:0;right:0;top:0;bottom:0;display:flex;justify-content:center;align-items:center;flex-direction:column;animation:nuxtLoadingIn 10s ease;-webkit-animation:nuxtLoadingIn 10s ease;animation-fill-mode:forwards;overflow:hidden}@keyframes nuxtLoadingIn{0%{visibility:hidden;opacity:0}20%{visibility:visible;opacity:0}100%{visibility:visible;opacity:1}}@-webkit-keyframes nuxtLoadingIn{0%{visibility:hidden;opacity:0}20%{visibility:visible;opacity:0}100%{visibility:visible;opacity:1}}#nuxt-loading>div,#nuxt-loading>div:after{border-radius:50%;width:5rem;height:5rem}#nuxt-loading>div{font-size:10px;position:relative;text-indent:-9999em;border:.5rem solid #f5f5f5;border-left:.5rem solid #000;-webkit-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0);-webkit-animation:nuxtLoading 1.1s infinite linear;animation:nuxtLoading 1.1s infinite linear}#nuxt-loading.error>div{border-left:.5rem solid #ff4500;animation-duration:5s}@-webkit-keyframes nuxtLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes nuxtLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}</style><script>window.addEventListener("error",function(){var e=document.getElementById("nuxt-loading");e&&(e.className+=" error")})</script><div id="nuxt-loading" aria-live="polite" role="status"><div>Loading...</div></div></div><script>window.__NUXT__={config:{},staticAssetsBase:"/vue-lazily/_nuxt/static/1611228810"}</script>
<script src="/vue-lazily/_nuxt/1f72591.js"></script><script src="/vue-lazily/_nuxt/5c69d6b.js"></script><script src="/vue-lazily/_nuxt/b18b62c.js"></script><script src="/vue-lazily/_nuxt/ffa1d89.js"></script></body>
</html>
1 change: 1 addition & 0 deletions docs/_nuxt/1f72591.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/_nuxt/27eb9e4.js

This file was deleted.

0 comments on commit 0a8a738

Please sign in to comment.