@abcum/ember-internet 中文文档教程
ember-internet
用于在 Ember.js 应用程序中处理连接状态的实用程序。
Usage
Installation
ember install @abcum/ember-internet
Introduction
ember-internet 插件启用 响应互联网连接状态的变化。 这可以根据当前的互联网连接状态自定义通知、行为和样式。
完整的连接状态对象在所有路由、控制器和组件中可用。
Examples
显示当前状态。
{{internet.status}}
在 Ember 控制器中使用当前路线信息。
export default Ember.Controller.extend({
status: Ember.observer('internet.status', function() {
// Do something with the current connection status
alert(`You are now ${internet.status}.`);
})
})
使用车把模板内的当前路线信息。
<button class="{{if internet.offline 'disabled'}}">
Save
</button>
Properties
以下属性可用。
Object property | Example output |
---|---|
internet.status | online |
internet.online | true |
internet.offline | false |
Development
make install
(install bower and ember-cli dependencies)make upgrade
(upgrade ember-cli to the specified version)make tests
(run all tests defined in the package)
ember-internet
A utility for working with connection status in an Ember.js app.
Usage
Installation
ember install @abcum/ember-internet
Introduction
The ember-internet addon enables responding to changes to the internet connection status. This enables customisation of notifications, behaviour, and styling depending on the current internet connection status.
The full connection status object is made available inside all routes, controllers, and components.
Examples
Displaying the current status.
{{internet.status}}
Using the current route info inside an Ember controller.
export default Ember.Controller.extend({
status: Ember.observer('internet.status', function() {
// Do something with the current connection status
alert(`You are now ${internet.status}.`);
})
})
Using the current route info inside handlebars templates.
<button class="{{if internet.offline 'disabled'}}">
Save
</button>
Properties
The following properties are available.
Object property | Example output |
---|---|
internet.status | online |
internet.online | true |
internet.offline | false |
Development
make install
(install bower and ember-cli dependencies)make upgrade
(upgrade ember-cli to the specified version)make tests
(run all tests defined in the package)