承接 mikeric/sightglass 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mikeric/sightglass

Composer 安装命令:

composer require mikeric/sightglass

包简介

Observable keypath engine.

README 文档

README

Observable keypath engine. Facilitaties building your own composable keypaths by way of defining adapters. This module was originally extracted from the Rivets.js data binding + templating library.

Installation

Install with npm, component(1) or bower (recommended).

$ bower install sightglass

API

sightglass.adapters

Before being able to observe an object with sightglass, you need to define at least one adapter to compose your keypaths with. Adapters are just objects that respond to observe, unobserve and get. Keys on the sightglass.adapters object are the separators you will use when composing your keypaths.

sightglass.adapters['.'] = {
  observe: function(obj, key, callback) {},
  unobserve: function(obj, key, callback) {},
  get: function(obj, key) {},
  set: function(obj, key, value) {}
}

sightglass.root

Sightglass also needs to know about a default root adapter. This is only required for keypaths that aren't prepended with an adapter key. For example, if your default root adapter is set to ., then the keypath hello:world will get parsed as .hello:world.

sightglass.root = '.'

sightglass(obj, keypath, callback, [options])

Observes the full keypath on the provided object. The callback is called whenever the end value of the keypath changes (this could happen from any intermediary objects in the keypath changing, in addition to the property at the end of the keypath changing).

sightglass(obj, 'user.address:city', function() {})

You can optionally pass in a fourth argument to extend the default options. Adapters defined here will only be available locally to the observer. All globally defined adapters will also be available to the observer, unless overridden by using an existing separator key.

sightglass(obj, keypath, callback, {
  root: ':',
  adapters: {':': {
    observe: function(obj, key, callback) {},
    unobserve: function(obj, key, callback) {},
    get: function(obj, key) {},
    set: function(obj, key, value) {}
  }}
})

Returns an Observer instance that you can hold on to for later (see Observer API below).

Observer API

observer.value()

Reads the current end value of the observed keypath. Returns undefined if the full keypath is unreachable.

observer.setValue()

Sets the value on the tail property of the observed object (the last segment in the keypath). Calling setValue when the full keypath is unreachable is a no-op.

observer.setValue('Vancouver')

observer.update()

Recomputes the entire keypath, attaching observers for every key or correcting old observers on objects in the keypath that have since changed.

If your adapter's subscribe function is implemented properly, this function will get called automatically when any intermediary key in the keypath changes, so you shouldn't need to call this function. However, if your keypath makes use of an adapter that does not subscribe for changes, then you will need to call this function manually after making changes to that segment in your keypath.

observer.unobserve()

Unobserves the entire keypath.

Contributing

Bug Reporting

  1. Ensure the bug can be reproduced on the latest master.
  2. Open an issue on GitHub and include an isolated JSFiddle demonstration of the bug. The more information you provide, the easier it will be to validate and fix.

Pull Requests

  1. Fork the repository and create a topic branch.
  2. Be sure to associate commits to their corresponding issue using [#1] or [Closes #1] if the commit resolves the issue.
  3. Push to your fork and submit a pull-request with an explanation and reference to the original issue (if there is one).

mikeric/sightglass 适用场景与选型建议

mikeric/sightglass 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「engine」 「observable」 「observe」 「keypath」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mikeric/sightglass 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mikeric/sightglass 我们能提供哪些服务?
定制开发 / 二次开发

基于 mikeric/sightglass 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 8
  • Forks: 20
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-31