精华内容
下载资源
问答
  • Events

    2016-11-22 20:12:07
    一、Event是在程序中一个发布-订阅风格的事件系统用来发送和响应应用程序级别的事件...constructor(public events: Events) {} // 第一个页面(当user创建时) function createUser(user) { console.log('User created!

    一、Event是在程序中一个发布-订阅风格的事件系统用来发送和响应应用程序级别的事件。

    import { Events } from 'ionic-angular';
    
    constructor(public events: Events) {}
    
    // 第一个页面(当user创建时)
    function createUser(user) {
      console.log('User created!')
      events.publish('user:created', user);
    }
    
    // 第二个页面(监听user创建事件)
    events.subscribe('user:created', (userEventData) => {
      // userEventData 是一个数组, so grab our first and only arg
      console.log('Welcome', userEventData[0]);
    });


    二、成员变量

    1、subscribe(topic, handler)

    事件订阅的主题,事件将触发他提供的方法。

    topic  string  订阅的主题

    handler  function  事件处理方法


    2、unsubscribe(topic,handler)

    取消签署的主题,你的handler将不再接收publish到主题事件

    会返回true如果handler被移除


    3、publish(topic, eventData)

    提交一个event给指定的topic

    展开全文
  • EVENTS

    千次阅读 2006-09-21 16:25:00
    /* * $Id: Events.java,v 1.5 2005/11/29 16:00:17 blowagie Exp $ * $Name: $ * * This code is part of the iText Tutorial. * You can find the complete tutorial at the following address:
     
    
    /*
     * $Id: Events.java,v 1.5 2005/11/29 16:00:17 blowagie Exp $
     * $Name:  $
     *
     * This code is part of the 'iText Tutorial'.
     * You can find the complete tutorial at the following address:
     * http://itextdocs.lowagie.com/tutorial/
     *
     * This code is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     *
     * itext-questions@lists.sourceforge.net
     */
    package com.lowagie.examples.directcontent.pageevents;
    
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.EmptyStackException;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.TreeSet;
    
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    
    import com.lowagie.text.Chunk;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.ElementTags;
    import com.lowagie.text.PageSize;
    import com.lowagie.text.Paragraph;
    import com.lowagie.text.Rectangle;
    import com.lowagie.text.TextElementArray;
    import com.lowagie.text.markup.MarkupTags;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfPageEventHelper;
    import com.lowagie.text.pdf.PdfTemplate;
    import com.lowagie.text.pdf.PdfWriter;
    import com.lowagie.text.xml.SAXmyHandler;
    import com.lowagie.text.xml.TagMap;
    import com.lowagie.text.xml.XmlPeer;
    
    /**
     * Example that takes an XML file, converts it to PDF and adds all kinds of
     * extra's, such as an alternating header, a footer with page x of y, a page
     * with metadata,...
     */
    public class Events {
    
    	/**
    	 * This is an example of a PageEvents class you should write.
    	 * This is an inner class to keep all the code of the example in one file.
    	 * If you want to use a PageEvent, you may want to put the code in a separate class.
    	 */
    
    	class MyPageEvents extends PdfPageEventHelper {
    
    		/** we will keep a list of speakers */
    		TreeSet speakers = new TreeSet();
    
    		/** This is the contentbyte object of the writer */
    		PdfContentByte cb;
    
    		/** we will put the final number of pages in a template */
    		PdfTemplate template;
    
    		/** this is the BaseFont we are going to use for the header / footer */
    		BaseFont bf = null;
    
    		/** this is the current act of the play */
    		String act = "";
    		
    		/**
    		 * Every speaker will be tagged, so that he can be added to the list of speakers.
    		 * @see com.lowagie.text.pdf.PdfPageEventHelper#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
    		 */
    		public void onGenericTag(PdfWriter writer, Document document,
    				Rectangle rect, String text) {
    			speakers.add(new Speaker(text));
    		}
    
    		/**
    		 * The first thing to do when the document is opened, is to define the BaseFont,
    		 * get the Direct Content object and create the template that will hold the final
    		 * number of pages.
    		 * @see com.lowagie.text.pdf.PdfPageEventHelper#onOpenDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
    		 */
    		public void onOpenDocument(PdfWriter writer, Document document) {
    			try {
    				bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
    						BaseFont.NOT_EMBEDDED);
    				cb = writer.getDirectContent();
    				template = cb.createTemplate(50, 50);
    			} catch (DocumentException de) {
    			} catch (IOException ioe) {
    			}
    		}
    
    		/**
    		 * Every ACT is seen as a Chapter. We get the title of the act, so that
    		 * we can display it in the header.
    		 * @see com.lowagie.text.pdf.PdfPageEventHelper#onChapter(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, float, com.lowagie.text.Paragraph)
    		 */
    		public void onChapter(PdfWriter writer, Document document,
    				float paragraphPosition, Paragraph title) {
    			StringBuffer buf = new StringBuffer();
    			for (Iterator i = title.getChunks().iterator(); i.hasNext();) {
    				Chunk chunk = (Chunk) i.next();
    				buf.append(chunk.content());
    			}
    			act = buf.toString();
    		}
    
    		/**
    		 * After the content of the page is written, we put page X of Y
    		 * at the bottom of the page and we add either "Romeo and Juliet"
    		 * of the title of the current act as a header.
    		 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
    		 */
    		public void onEndPage(PdfWriter writer, Document document) {
    			int pageN = writer.getPageNumber();
    			String text = "Page " + pageN + " of ";
    			float len = bf.getWidthPoint(text, 8);
    			cb.beginText();
    			cb.setFontAndSize(bf, 8);
    			cb.setTextMatrix(280, 30);
    			cb.showText(text);
    			cb.endText();
    			cb.addTemplate(template, 280 + len, 30);
    			cb.beginText();
    			cb.setFontAndSize(bf, 8);
    			cb.setTextMatrix(280, 820);
    			if (pageN % 2 == 1) {
    				cb.showText("Romeo and Juliet");
    			} else {
    				cb.showText(act);
    			}
    			cb.endText();
    		}
    
    		/**
    		 * Just before the document is closed, we add the final number of pages to
    		 * the template.
    		 * @see com.lowagie.text.pdf.PdfPageEventHelper#onCloseDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
    		 */
    		public void onCloseDocument(PdfWriter writer, Document document) {
    			template.beginText();
    			template.setFontAndSize(bf, 8);
    			template.showText(String.valueOf(writer.getPageNumber() - 1));
    			template.endText();
    		}
    
    		/**
    		 * Getting the list of speakers.
    		 * @return	a list of speakers and the number of occurances.
    		 */
    		public TreeSet getSpeakers() {
    			return speakers;
    		}
    	}
    
    	/**
    	 * Gets a PageEvents object.
    	 * @return a new PageEvents object
    	 */
    	public MyPageEvents getPageEvents() {
    		return new MyPageEvents();
    	}
    	/**
    	 * Gets a Handler object.
    	 * @param document  the document on which the handler operates
    	 * @return a Handler object
    	 * @throws IOException
    	 */
    	public MyHandler getXmlHandler(Document document) throws IOException {
    		try {
    			return new MyHandler(document, new RomeoJulietMap());
    		} catch (DocumentException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		return null;
    	}
    	
    	/**
    	 * Converts a play in XML into PDF.
    	 * @param args no arguments needed
    	 */
    	public static void main(String[] args) {
    
    		System.out.println("Romeo and Juliet");
    
    		// step 1: creation of a document-object
    		Document document = new Document(PageSize.A4, 80, 50, 30, 65);
    
    		try {
    			// step 2:
    			// we create a writer that listens to the document
    			// and directs a XML-stream to a file
    			PdfWriter writer = PdfWriter.getInstance(document,
    					new FileOutputStream("RomeoJuliet.pdf"));
    
    			// create add the event handler
    			MyPageEvents events = new Events().getPageEvents();
    			writer.setPageEvent(events);
    
    			// step 3: we create a parser and set the document handler
    			SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    
    			// step 4: we parse the document
    			parser.parse("playRomeoJuliet.xml", new Events().getXmlHandler(document));
    
    			document.newPage();
    			Speaker speaker;
    			for (Iterator i = events.getSpeakers().iterator(); i.hasNext();) {
    				speaker = (Speaker) i.next();
    				document.add(new Paragraph(speaker.getName() + ": "
    						+ speaker.getOccurrance() + " speech blocks"));
    			}
    			document.close();
    
    		} catch (Exception e) {
    			e.printStackTrace();
    			System.err.println(e.getMessage());
    		}
    	}
    
    	/**
    	 * Special implementation of het XML handler.
    	 * It adds a paragraph after each SPEAKER block and
    	 * avoids closing the document after the final closing tag.
    	 */
    	class MyHandler extends SAXmyHandler {
    
    		/**
    		 * We have to override the constructor
    		 * @param document	the Document object
    		 * @param tagmap	the tagmap
    		 * @throws IOException
    		 * @throws DocumentException
    		 */
    		public MyHandler(Document document, HashMap tagmap) throws DocumentException, IOException {
    			super(document, tagmap);
    		}
    
    		/**
    		 * We only alter the handling of some endtags.
    		 * @param uri	the uri of the namespace
    		 * @param lname	the local name of the tag
    		 * @param name	the name of the tag
    		 */
    		public void endElement(String uri, String lname, String name) {
    			if (myTags.containsKey(name)) {
    				XmlPeer peer = (XmlPeer) myTags.get(name);
    				// we don't want the document to be close
    				// because we are going to add a page after the xml is parsed
    				if (isDocumentRoot(peer.getTag())) {
    					return;
    				}
    				handleEndingTags(peer.getTag());
    				// we want to add a paragraph after the speaker chunk
    				if ("SPEAKER".equals(name)) {
    					try {
    						TextElementArray previous = (TextElementArray) stack
    								.pop();
    						previous.add(new Paragraph(16));
    						stack.push(previous);
    					} catch (EmptyStackException ese) {
    					}
    				}
    			} else {
    				handleEndingTags(name);
    			}
    		}
    	}
    
    	/**
    	 * Normally you either choose to use a HashMap with XmlPeer objects,
    	 * or a TagMap object that reads a TagMap in XML.
    	 * Here we used a hybrid solution (for educational purposes only!)
    	 * with on one side the tags in the XML tagmap, on the other side
    	 * an XmlPeer object that overrides the properties of one of the tags.
    	 */
    
    	class RomeoJulietMap extends TagMap {
    
    		/**
    		 * Constructs a TagMap based on an XML file
    		 * and/or on XmlPeer objects that are added.
    		 * @throws IOException
    		 */
    		public RomeoJulietMap() throws IOException {
    			super(new FileInputStream("tagmapRomeoJuliet.xml"));
    			XmlPeer peer = new XmlPeer(ElementTags.CHUNK, "SPEAKER");
    			peer.addValue(MarkupTags.CSS_KEY_FONTSIZE, "10");
    			peer.addValue(MarkupTags.CSS_KEY_FONTWEIGHT, MarkupTags.CSS_VALUE_BOLD);
    			peer.addValue(ElementTags.GENERICTAG, "");
    			put(peer.getAlias(), peer);
    		}
    	}
    
    	/**
    	 * This object contains a speaker and a number of occurrances in the play
    	 */
    
    	class Speaker implements Comparable {
    
    		// name of the speaker
    		private String name;
    
    		// number of occurrances
    		private int occurrance = 1;
    
    		/**
    		 * One of the speakers in the play.
    		 * @param name
    		 */
    		public Speaker(String name) {
    			this.name = name;
    		}
    
    		/**
    		 * Gets the name of the speaker.
    		 * @return a name
    		 */
    		public String getName() {
    			return name;
    		}
    
    		/**
    		 * Gets the number of occurances of the speaker.
    		 * @return a number of textblocks
    		 */
    		public int getOccurrance() {
    			return occurrance;
    		}
    
    		/**
    		 * There is something odd going on in this compareTo.
    		 * Do you see it?
    		 * @param o an other speaker object
    		 * @see java.lang.Comparable#compareTo(java.lang.Object)
    		 */
    		public int compareTo(Object o) {
    			Speaker otherSpeaker = (Speaker) o;
    			if (otherSpeaker.getName().equals(name)) {
    				this.occurrance += otherSpeaker.getOccurrance();
    				otherSpeaker.occurrance = this.occurrance;
    				return 0;
    			}
    			return name.compareTo(otherSpeaker.getName());
    		}
    	}
    }
    展开全文
  • <div><p>According to the discussion in #180 the first step to removing the jquery events is to trigger native events in addition to the jquery ones. <p>This PR triggers native events everywhere that ...
  • Touch Events

    2019-05-09 21:41:14
  • Internal events framework

    2020-12-09 07:22:00
    <div><p>The events framework allows events to be generated and broadcast internally within the GD2 cluster, with <code>events.Broadcast(Event)</code>. <p><code>Event</code>s are either local or global...
  • All events endpoint

    2020-12-08 20:41:21
    <div><p>This is the all BridgeTroll and external events JSON endpoint for RailsBridge. This way we can grab all events and then process them on our side. <p>I added tests to the events controller spec...
  • Events APIs integration

    2020-12-09 11:03:14
    <div><p>Events APIs support is required in Gd2, Currently <code>glustereventsd</code> is independent daemon outside Glusterd, So that it can receive client events even if Glusterd is down. In future ...
  • <p>I have a div : </p><div id="calendar"></div> and a dropdown that is changing the $scope.events. <p>1) I load some events on the calendar // Intialize scope values $scope.events = []; scope....
  • Created Generic Events subsection, and added <code>onError</code> & <code>onLoad</code> events –– (https://reactjs.org/docs/events.html#generic-events) <p>Based on suggestion by in following ...
  • Fabric Events Examples

    2018-10-17 22:11:20
    Events client This sample client demonstrates how to connect to a peer to receive block events. Block events come in the form of either full blocks as they have been committed to the ledger or filtere...

    Events client

    This sample client demonstrates how to connect to a peer to receive block
    events. Block events come in the form of either full blocks as they have been
    committed to the ledger or filtered blocks (a minimal set of information about
    the block) which includes the transaction ids, transaction statuses, and any
    chaincode events associated with the transaction.

    Events service interface

    Starting with v1.1, two new event services are available:

    service Deliver {
        // deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with Payload data as a marshaled orderer.SeekInfo message,
        // then a stream of block replies is received.
        rpc Deliver (stream common.Envelope) returns (stream DeliverResponse) {
        }
        // deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with Payload data as a marshaled orderer.SeekInfo message,
        // then a stream of **filtered** block replies is received.
        rpc DeliverFiltered (stream common.Envelope) returns (stream DeliverResponse) {
        }
    }
    

    This sample demonstrates connecting to both of these services.

    General use

    cd fabric/examples/events/eventsclient
    go build
    

    You will see the executable eventsclient if there are no compilation errors.

    Next, to start receiving block events from a peer with TLS enabled, run the
    following command:

    CORE_PEER_LOCALMSPID=<msp-id> CORE_PEER_MSPCONFIGPATH=<path to MSP folder> ./eventsclient -channelID=<channel-id> -filtered=<true or false> -tls=true -clientKey=<path to the client key> -clientCert=<path to the client TLS certificate> -rootCert=<path to the server root CA certificate>
    

    If the peer is not using TLS you can run:

    CORE_PEER_LOCALMSPID=<msp-id> CORE_PEER_MSPCONFIGPATH=<path to MSP folder> ./eventsclient -channelID=<channel-id> -filtered=<true or false> -tls=false
    

    The peer will begin delivering block events and print the output to the console.

    Example with the e2e_cli example

    The events client sample can be used with TLS enabled or disabled. By default,
    the e2e_cli example will have TLS enabled. In order to allow the events client
    to connect to peers created by the e2e_cli example with TLS enabled, the easiest
    way would be to map 127.0.0.1 to the hostname of the peer that you are
    connecting to, such as peer0.org1.example.com. For example on *nix based
    systems this would be an entry in /etc/hosts file.

    If you would prefer to disable TLS, you may do so by setting
    CORE_PEER_TLS_ENABLED=false in docker-compose-cli.yaml and
    base/peer-base.yaml as well as
    ORDERER_GENERAL_TLS_ENABLED=false inbase/docker-compose-base.yaml.

    Next, run the e2e_cli example.

    Once the “All in one” command:

    ./network_setup.sh up
    

    has completed, attach the event client to peer peer0.org1.example.com by doing
    the following:

    • If TLS is enabled:
      • to receive full blocks:
    CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.Org1.example.com/msp ./eventsclient -server=peer0.org1.example.com:7051 -channelID=mychannel -filtered=false -tls=true -clientKey=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/client.key -clientCert=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/client.crt -rootCert=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/ca.crt
    
    • to receive filtered blocks:
    CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.Org1.example.com/msp ./eventsclient -server=peer0.org1.example.com:7051 -channelID=mychannel -filtered=true -tls=true -clientKey=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/client.key -clientCert=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/client.crt -rootCert=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@Org1.example.com/tls/ca.crt
    
    • If TLS is disabled:
      • to receive full blocks:
    CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.Org1.example.com/msp ./eventsclient -server=peer0.org1.example.com:7051 -channelID=mychannel -filtered=false -tls=false
    
    • to receive filtered blocks:
    CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.Org1.example.com/msp ./eventsclient -server=peer0.org1.example.com:7051 -channelID=mychannel -filtered=true -tls=false
    
    展开全文
  • events-pubsub-</em></li><li>cloud-run-events-<em> to events-system-</em> (non-namespace & not service accounts)</li><li>cloud-run-events -> events-system (namespace only)</li><li>test-cloud-...
  • <div><p>In order to add Events card to Dashboards I needed to refactor <code>events.jsx</code> to be able to render events in a way which fits. <p>I decoupled fetching events logic from rendering and ...
  • <p>I am new to this plugin and need to display both google events and events from the database on the same calendar. I have it working with either google events or events from the database, but not ...
  • <div><p>Both SDL2 and the browser attempt to simulate mouse events from touch events. As a result we may get duplicates. <p>By default, on touch event on the canvas we generates fake mouse events with...
  • m trying to get all events for a conversation using hangups 0.4.9, and am running into an issue. <p>Basically, my code looks like this: <pre><code>py def get_all_events(callback, hangout, event_id=...
  • DOM events

    2014-06-04 15:16:13
    Here are some common DOM events: Mouse Events Keyboard Events Form Events Document/Window Events click keypress submit load dblclick keydown change re
  • events 事件

    2015-12-18 13:49:34
    Events 事件jsPlumb supports binding to several different events on Connections, Endpoints and Overlays, and also on the jsPlumb object itself. jsPlumb Events [connection](#evt-connection) [c
  • <div><p>It looks like the categories for focus events are inconsistent, but I'm not sure what they should be: - <a href="http://api.jquery.com/focus/">.focus()</a>: Events > Form Events | Forms...
  • <div><p>Issue with <em>upcoming</em> events list. List isn't populating upcoming events on some content types. No disruption to lists already created/being used, but issues with list not ...
  • pointer-events

    2017-07-12 15:04:02
    pointer-events
  • <p>To get events to print on a dayploy I had to edit these lines in imaging/waveform/plot_day: <pre><code> 486 events = kwargs.get("events", []) 487 # Potentially download some events ...
  • node的events使用

    2020-04-07 17:44:44
    1. //安装 npm install events //引用 var events = require('events'); var eventEmitter = new events.EventEmitter(); //或者 // import { EventEmitter } from "events"; // var ...
  • vue1 events

    2019-03-21 10:06:51
    events 监听事件(包括子组件发射的事件)
  • ng-events 在 Angular 2 以上的版本中使用,类似于 ionic 中的 Events。可以使用 ng-events 注册一个全局事件,然后在需要的时候触发这个事件。 快速开始 npm install ng-events --save 在 Angular 6 以上的...
  • node--events

    2019-08-29 14:53:24
    node--events
  • I think this will require adding new flow events to blink, though I'm not sure exactly where. <p>Edit 2015 Dec 8 Currently, RAIL cannot find any associated events for CSS Animations. RAIL does not...
  • 以太坊中的Events和Logs

    万次阅读 2019-05-11 16:27:48
    以太坊中的事件(Events)和日志(Logs)是个特别让人困惑的概念,本文帮大家梳理。 首先,以太坊中的Events和Logs基本上算是同一个概念。Solidity和web3.js中称为Events,以太坊黄皮书中称为Logs。你可以理解为:...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 126,553
精华内容 50,621
关键字:

events