#NEWLINE# def connect( self , * connection_strings ) : #NEWLINE# #INDENT# " Connect a function to one or more events of this instance. Can\n        also be used as a decorator. See the\n        :func:`connect <flexx.event.connect>` decorator for more information.\n        \n        .. code-block:: py\n            \n            h = HasEvents()\n            \n            # Usage as a decorator\n            @h.connect('first_name', 'last_name')\n            def greet(*events):\n                print('hello %s %s' % (h.first_name, h.last_name))\n            \n            # Direct usage\n            h.connect(greet, 'first_name', 'last_name')\n        \n        " #NEWLINE# if ( ( not connection_strings ) or ( ( len ( connection_strings ) == 1 ) and callable ( connection_strings [ 0 ] ) ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'connect() needs one or more connection strings.' ) #NEWLINE# #UNINDENT# func = None #NEWLINE# if callable ( connection_strings [ 0 ] ) : #NEWLINE# #INDENT# func = connection_strings [ 0 ] #NEWLINE# connection_strings = connection_strings [ 1 : ] #NEWLINE# #UNINDENT# for s in connection_strings : #NEWLINE# #INDENT# if ( not ( isinstance ( s , str ) and ( len ( s ) > 0 ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Connection string must be nonempty strings.' ) #NEWLINE# #UNINDENT# #UNINDENT# def _connect( func ) : #NEWLINE# #INDENT# if ( not callable ( func ) ) : #NEWLINE# #INDENT# raise TypeError ( 'connect() decotator requires a callable.' ) #NEWLINE# #UNINDENT# return Handler ( func , connection_strings , self ) #NEWLINE# #UNINDENT# if ( func is not None ) : #NEWLINE# #INDENT# return _connect ( _connect ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return _connect