Giter VIP home page Giter VIP logo

s-offline's Introduction

s-offline ⚡️

Continuous Integration Ship js trigger GitHub release (latest SemVer) npm npm npm bundle size (version) npm type definitions DeepScan grade Snyk Vulnerabilities for GitHub Repo LGTM Alerts LGTM Grade GitHub contributors FOSSA

eslint prettier vite svelte typescript

Features

  • Detect offline & online events for your Svelte app, inspired from v-offline
  • Built from scratch using TypeScript

Table of Contents

Demo

Edit s-offline demo

Requirements

Installation

npm install --save s-offline

CDN: UNPKG | jsDelivr (available as window.SOffline)

Build Setup

# install dependencies
$ npm ci

# package the library
$ npm run build

Usage

import { SOffline } from 's-offline';

Example

Detailed Example (refer App.svelte)
<script>
  import SOffline from 's-offline';
  const handleNetworkChange = (status) => {
    console.log('event details: ', status);
  };
</script>

<SOffline
  pingUrl="https://bitly.com"
  on:detectedCondition="{handleNetworkChange}"
>
  <span slot="online" class="online"> 😊 </span>
  <span slot="offline" class="offline"> 🤕 </span>
</SOffline>

<style>
  .online {
    font-size: 10rem;
    text-align: center;
  }
  .offline {
    font-size: 10rem;
    text-align: center;
  }
</style>

API

Props

Name Type Required? Default Description
pingUrl String No https://google.com Pinging any url to double check if you're online or not.

Events

Name Returns Description
detectedCondition String Emits a boolean value

Built with

Contributing

  1. Fork it ( https://github.com/vinayakkulkarni/s-offline/fork )
  2. Create your feature branch (git checkout -b feat/new-feature)
  3. Commit your changes (git commit -Sam 'feat: add feature')
  4. Push to the branch (git push origin feat/new-feature)
  5. Create a new Pull Request

Note:

  1. Please contribute using GitHub Flow
  2. Commits & PRs will be allowed only if the commit messages & PR titles follow the conventional commit standard, read more about it here
  3. PS. Ensure your commits are signed. Read why

Author

s-offline © Vinayak, Released under the MIT License.
Authored and maintained by Vinayak Kulkarni with help from contributors (list).

vinayakkulkarni.dev · GitHub @vinayakkulkarni · Twitter @_vinayak_k

License

FOSSA Status

s-offline's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar fossabot avatar vinayakkulkarni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

s-offline's Issues

About pingUrl.

Hope you can change one. like 1.1.1.1 or other.

here is reason:

C:\Users\legiorange>ping google.com

正在 Ping google.com [172.217.194.101] 具有 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。

172.217.194.101 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),

We can see here is timeout.
We can't visit google on china.

Should s-offline poll to get current online/offline status

Hi, I tested the demo and when I go in dev tool in chrome I can set network to be offline and can see the demo rightly detect the offline status right away. Same when I enabled the network again in the dev tool

But when I switch off my internet, the browser does not seem to send any update to s-offline and the demo is not aware of changes.

One option could be that s-offline ping regularly (polling) to check offline/online status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.