{"id":21198383,"url":"https://github.com/netyouli/react-whc-notification","last_synced_at":"2025-07-10T05:32:52.166Z","repository":{"id":57347686,"uuid":"161288160","full_name":"netyouli/react-whc-notification","owner":"netyouli","description":"A react、vue、react native module to post and observer notification, it works on React 、React-Native  Vue、H5. (支持一对多发送通知消息、主要解决react、react-native、vue、h5夸组件页面之间的通信状态管理等)，该组件可以用来替代Redux，Vuex进行状态管理","archived":false,"fork":false,"pushed_at":"2019-06-18T11:03:30.000Z","size":9,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-28T17:19:41.681Z","etag":null,"topics":["notification","react","react-native","react-whc-notification","whc-notification"],"latest_commit_sha":null,"homepage":"http://www.wuhaichao.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netyouli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-11T06:33:00.000Z","updated_at":"2020-02-06T10:07:13.000Z","dependencies_parsed_at":"2022-08-28T03:01:38.049Z","dependency_job_id":null,"html_url":"https://github.com/netyouli/react-whc-notification","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2Freact-whc-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2Freact-whc-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2Freact-whc-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netyouli%2Freact-whc-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netyouli","download_url":"https://codeload.github.com/netyouli/react-whc-notification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225622929,"owners_count":17498168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notification","react","react-native","react-whc-notification","whc-notification"],"created_at":"2024-11-20T19:50:59.694Z","updated_at":"2024-11-20T19:51:00.817Z","avatar_url":"https://github.com/netyouli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-whc-notification\nA react、vue、react native module to post and observer notification, it works on React 、React-Native 、Vue、H5. (支持一对多发送通知消息、主要解决react、react-native、vue、h5夸组件页面之间的通信状态管理等)\n\n### 该组件可以用来替代Redux，Vuex进行状态管理，使用更加简单高效，强力推荐\n\n[ ![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/netyouli/react-whc-notification/pulls)\n[ ![NPM version](http://img.shields.io/npm/v/react-whc-notification.svg?style=flat)](https://www.npmjs.com/package/react-whc-notification)\n[![License MIT](http://img.shields.io/badge/license-MIT-orange.svg?style=flat)](https://raw.githubusercontent.com/crazycodeboy/react-whc-notification/master/LICENSE)\n\n\n## Content\n\n- [Installation](#installation)\n- [Getting started](#getting-started)\n- [API](#api)\n- [Contribution](#contribution)\n\n## Installation\n\n* 1.Run `npm i react-whc-notification --save`\n* 2.`import Notification from 'react-whc-notification'`\n\n## Getting started  \n\nAdd `react-whc-notification` to your js file.\n\n`import Notification from 'react-whc-notification'`\n\nAdd observer notification:\n\n```javascript\n constructor(props) {\n      super(props);\n      Notification.addObserver(this, 'ObserverNotificationName' ,(param) =\u003e {\n          console.log(param);\n      });\n\n      // 最后一个参数true用来补发通知（主要是用于监听已经发过的通知但是监听者还没来得及注册监听的情况）\n      Notification.addObserver(this, 'ObserverNotificationName' ,(param) =\u003e {\n          console.log(param);\n      }, true);\n  }\n\n```\n\nPost notification:\n\n```javascript\nNotification.post('ObserverNotificationName', '通知传递的参数可以是任意数据类型');\n```\n\nRemove specified observer notification:\n\n```javascript\ncomponentWillUnmount() {\n    Notification.removeObserver(this, 'ObserverNotificationName');\n}\n\n```\n\nRemove all observer notification:\n\n```javascript\ncomponentWillUnmount() {\n    Notification.removeObserver(this);\n}\n\n```\n\n## API\n\n\nMethod   |  Type     | Optional | Description\n----------------- | -------- | -------- | -----------\npost(string, any)   | function | true | post notification\naddObserver(object, string, function, boolean)  |   function  |  true   | observer notification\nremoveObserver(object, string)  |   function  |  true   | remove observer notification\n\n\n## Contribution\n\nIssues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.\n\nPull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.\n\n---\n\n**MIT Licensed**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetyouli%2Freact-whc-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetyouli%2Freact-whc-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetyouli%2Freact-whc-notification/lists"}