npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wx-notification-center

v1.0.1

Published

WxNotificationCenter - 微信小程序通知广播模式类,降低小程序开发的耦合度

Downloads

4

Readme

WxNotificationCenter

WxNotificationCenter - 微信小程序通知广播模式类,降低小程序开发的耦合度

信息

来自微信小程序开发论坛 http://weappdev.com/ 垂直微信小程序开发论坛

版本信息

version 0.1

效果预览

WxNotificationCenter效果预览gif

使用

  1. copy 文件 WxNotificationCenter.js 到你的开发目录中

  2. 引入 WxNotificationCenter.js 在你需要的js

var WxNotificationCenter = require("../../WxNotificationCenter/WxNotificationCenter.js");
  1. 注册通知
// 最好在onLoad中进行
/**
* addNotification
* 注册通知对象方法
* 
* 参数:
* name: 注册名,一般let在公共类中
* selector: 对应的通知方法,接受到通知后进行的动作
* observer: 注册对象,指Page对象,可选,不填写的话在remove中会失效
*/

var that = this
WxNotificationCenter.addNotification("testNotificationName",that.testNotificationFn,that)
  1. 发送通知
WxNotificationCenter.postNotificationName("testNotificationName");
  1. 移除通知
// 移除通知在本也完成
WxNotificationCenter.removeNotification("testTabNotificationName",that)

特性

  • 支持注册、发送、移除通知
  • 支持传参,字典等

源码分析

  • var __notices = [];

存放通知数组

  • addNotification 注册方法

     * addNotification
     * 注册通知对象方法
     * 
     * 参数:
     * name: 注册名,一般let在公共类中
     * selector: 对应的通知方法,接受到通知后进行的动作
     * observer: 注册对象,指Page对象
     */
    
  • postNotificationName 发送方法

    /**
      * postNotificationName
      * 发送通知方法
      * 
      * 参数:
      * name: 已经注册了的通知
      * info: 携带的参数
      */
    
     function postNotificationName(name, info)
  • removeNotification 移除方法

    /**
     * removeNotification
     * 移除通知方法
     * 
     * 参数:
     * name: 已经注册了的通知
     * observer: 移除的通知所在的Page对象
     */
    
    function removeNotification(name,observer)

拓展阅读

  • 什么叫做通知广播模式

本类借鉴iOS开发中的NSNotificationCenter的消息模式进行开发

可阅读: 细说KVO & KVC & NSNotificationCenter那些事

  • 通知广播模式的使用场景
  • 多级页面传值

来源

来自微信小程序开发论坛 http://weappdev.com/ 垂直微信小程序开发论坛