interfaces

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: BSD-3-Clause Imports: 0 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICommand

type ICommand interface {
	INotifier

	/*
	  Execute the ICommand's logic to handle a given INotification.

	  - parameter note: an INotification to handle.
	*/
	Execute(notification INotification)
}

ICommand The interface definition for a PureMVC Command.

type IController

type IController interface {
	/*
	  Initialize the Multiton Controller instance.
	*/
	InitializeController()

	/*
	  Register a particular ICommand class as the handler
	  for a particular INotification.

	  - parameter notificationName: the name of the INotification
	  - parameter factory: reference that returns ICommand
	*/
	RegisterCommand(notificationName string, factory func() ICommand)

	/*
	  Execute the ICommand previously registered as the
	  handler for INotifications with the given notification name.

	  - parameter notification: the INotification to execute the associated ICommand for
	*/
	ExecuteCommand(notification INotification)

	/*
	  Remove a previously registered ICommand to INotification mapping.

	  - parameter notificationName: the name of the INotification to remove the ICommand mapping for
	*/
	RemoveCommand(notificationName string)

	/*
	  Check if a Command is registered for a given Notification

	  - parameter notificationName:
	  - returns: whether a Command is currently registered for the given notificationName.
	*/
	HasCommand(notificationName string) bool
}

IController The interface definition for a PureMVC Controller.

In PureMVC, an IController implementor follows the 'Command and Controller' strategy, and assumes these responsibilities:

* Remembering which ICommands are intended to handle which INotifications.

* Registering itself as an IObserver with the View for each INotification that it has an ICommand mapping for.

* Creating a new instance of the proper ICommand to handle a given INotification when notified by the View.

* Calling the ICommand's execute method, passing in the INotification.

type IFacade

type IFacade interface {
	INotifier

	/*
	  Initialize the Multiton Facade instance.

	  Called automatically by the constructor. Override in your
	  subclass to do any subclass specific initializations. Be
	  sure to call super.initializeFacade(), though.
	*/
	InitializeFacade()

	/*
	  Initialize the Controller.
	*/
	InitializeController()

	/*
		Initialize the Model.
	*/
	InitializeModel()

	/*
		Initialize the View.
	*/
	InitializeView()

	/*
	  Register an ICommand with the Controller.

	  - parameter noteName: the name of the INotification to associate the ICommand with.
	  - parameter factory: reference that returns ICommand
	*/
	RegisterCommand(notificationName string, factory func() ICommand)

	/*
	  Remove a previously registered ICommand to INotification mapping from the Controller.

	  - parameter notificationName: the name of the INotification to remove the ICommand mapping for
	*/
	RemoveCommand(notificationName string)

	/*
	  Check if a Command is registered for a given Notification

	  - parameter notificationName:
	  - returns: whether a Command is currently registered for the given notificationName.
	*/
	HasCommand(notificationName string) bool

	/*
	  Register an IProxy with the Model by name.

	  - parameter proxy: the IProxy to be registered with the Model.
	*/
	RegisterProxy(proxy IProxy)

	/*
	  Retrieve a IProxy from the Model by name.

	  - parameter proxyName: the name of the IProxy instance to be retrieved.
	  - returns: the IProxy previously regisetered by proxyName with the Model.
	*/
	RetrieveProxy(proxyName string) IProxy

	/*
	  Remove an IProxy instance from the Model by name.

	  - parameter proxyName: the IProxy to remove from the Model.
	  - returns: the IProxy that was removed from the Model
	*/
	RemoveProxy(proxyName string) IProxy

	/*
	  Check if a Proxy is registered

	  - parameter proxyName:
	  - returns: whether a Proxy is currently registered with the given proxyName.
	*/
	HasProxy(proxyName string) bool

	/*
	  Register an IMediator instance with the View.

	  - parameter mediator: a reference to the IMediator instance
	*/
	RegisterMediator(mediator IMediator)

	/*
	  Retrieve an IMediator instance from the View.

	  - parameter mediatorName: the name of the IMediator instance to retrievve
	  - returns: the IMediator previously registered with the given mediatorName.
	*/
	RetrieveMediator(mediatorName string) IMediator

	/*
	  Remove a IMediator instance from the View.

	  - parameter mediatorName: name of the IMediator instance to be removed.
	  - returns: the IMediator instance previously registered with the given mediatorName.
	*/
	RemoveMediator(mediatorName string) IMediator

	/*
	  Check if a Mediator is registered or not

	  - parameter mediatorName:
	  - returns: whether a Mediator is registered with the given mediatorName.
	*/
	HasMediator(mediatorName string) bool

	/*
		Notify Observers.

		This method is left public mostly for backward
		compatibility, and to allow you to send custom
		notification classes using the facade.

		Usually you should just call sendNotification
		and pass the parameters, never having to
		construct the notification yourself.

		- parameter notification: the INotification to have the View notify Observers of.
	*/
	NotifyObservers(notification INotification)
}

IFacade The interface definition for a PureMVC Facade.

The Facade Pattern suggests providing a single class to act as a central point of communication for a subsystem.

In PureMVC, the Facade acts as an interface between the core MVC actors (Model, View, Controller) and the rest of your application.

type IMediator

type IMediator interface {
	INotifier

	/*
	  Get the IMediator instance name
	*/
	GetMediatorName() string

	/*
	  Get the IMediator's view component.
	*/
	GetViewComponent() interface{}

	/*
	  Set the IMediator's view component.
	*/
	SetViewComponent(viewComponent interface{})

	/*
	  List INotification interests.

	  - returns: an Array of the INotification names this IMediator has an interest in.
	*/
	ListNotificationInterests() []string

	/*
	  Handle an INotification.

	  - parameter notification: the INotification to be handled
	*/
	HandleNotification(notification INotification)

	/*
	  Called by the View when the Mediator is registered
	*/
	OnRegister()

	/*
	  Called by the View when the Mediator is removed
	*/
	OnRemove()
}

IMediator The interface definition for a PureMVC Mediator.

In PureMVC, IMediator implementors assume these responsibilities:

* Implement a common method which returns a list of all INotifications the IMediator has interest in.

* Implement a notification callback method.

* Implement methods that are called when the IMediator is registered or removed from the View.

Additionally, IMediators typically:

* Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior.

* In Flash-based apps, this is often the place where event listeners are added to view components, and their handlers implemented.

* Respond to and generate INotifications, interacting with of the rest of the PureMVC app.

When an IMediator is registered with the IView, the IView will call the IMediator's listNotificationInterests method. The IMediator will return an Array of INotification names which it wishes to be notified about.

The IView will then create an Observer object encapsulating that IMediator's (handleNotification) method and register it as an Observer for each INotification name returned by listNotificationInterests.

type IModel

type IModel interface {
	/*
	  Initialize the Model instance.
	*/
	InitializeModel()

	/*
	  Register an IProxy instance with the Model.

	  - parameter proxyName: the name to associate with this IProxy instance.
	  - parameter proxy: an object reference to be held by the Model.
	*/
	RegisterProxy(proxy IProxy)

	/*
	  Retrieve an IProxy instance from the Model.

	  - parameter proxyName:
	  - returns: the IProxy instance previously registered with the given proxyName.
	*/
	RetrieveProxy(proxyName string) IProxy

	/*
	  Remove an IProxy instance from the Model.

	  - parameter proxyName: name of the IProxy instance to be removed.
	  - returns: the IProxy that was removed from the Model
	*/
	RemoveProxy(proxyName string) IProxy

	/*
	  Check if a Proxy is registered

	  - parameter proxyName:
	  - returns: whether a Proxy is currently registered with the given proxyName.
	*/
	HasProxy(proxyName string) bool
}

IModel The interface definition for a PureMVC Model.

In PureMVC, IModel implementors provide access to IProxy objects by named lookup.

An IModel assumes these responsibilities:

* Maintain a cache of IProxy instances

* Provide methods for registering, retrieving, and removing IProxy instances

type INotification

type INotification interface {
	/*
	  Get the name of the INotification instance.
	*/
	Name() string

	/*
	  Set the body of the INotification instance
	*/
	SetBody(body interface{})

	/*
	  Get the body of the INotification instance
	*/
	Body() interface{}

	/*
	  Set the type of the INotification instance
	*/
	SetType(t string)

	/*
	  Get the type of the INotification instance
	*/
	Type() string

	/*
	  Get the string representation of the INotification instance
	*/
	String() string
}

INotification The interface definition for a PureMVC Notification.

PureMVC does not rely upon underlying event models such as the one provided with Flash, and ActionScript 3 does not have an inherent event model.

The Observer Pattern as implemented within PureMVC exists to support event-driven communication between the application and the actors of the MVC triad.

Notifications are not meant to be a replacement for Events in Flex/Flash/AIR. Generally, IMediator implementors place event listeners on their view components, which they then handle in the usual way. This may lead to the broadcast of Notifications to trigger ICommands or to communicate with other IMediators. IProxy and ICommand instances communicate with each other and IMediators by broadcasting INotifications.

A key difference between Flash Events and PureMVC Notifications is that Events follow the 'Chain of Responsibility' pattern, 'bubbling' up the display hierarchy until some parent component handles the Event, while PureMVC Notifications follow a 'Publish/Subscribe' pattern. PureMVC classes need not be related to each other in a parent/child relationship in order to communicate with one another using Notifications.

type INotifier

type INotifier interface {
	/*
	  Send a INotification.

	  Convenience method to prevent having to construct new
	  notification instances in our implementation code.

	  - parameter notificationName: the name of the notification to send
	  - parameter body: the body of the notification (optional)
	  - parameter type: the type of the notification (optional)
	*/
	SendNotification(notificationName string, body interface{}, _type string)

	/*
	  Initialize this INotifier instance.

	  This is how a Notifier get to Calls to
	  sendNotification or to access the
	  facade will fail until after this method
	  has been called.
	*/
	InitializeNotifier(key string)
}

INotifier The interface definition for a PureMVC Notifier.

MacroCommand, Command, Mediator and Proxy all have a need to send Notifications.

The INotifier interface provides a common method called sendNotification that relieves implementation code of the necessity to actually construct Notifications.

The Notifier class, which all of the above mentioned classes extend, also provides an initialized reference to the Facade Singleton, which is required for the convienience method for sending Notifications, but also eases implementation as these classes have frequent Facade interactions and usually require access to the facade anyway.

type IObserver

type IObserver interface {
	/*
	  Set the notification method.

	  The notification method should take one parameter of type INotification

	  - parameter notifyMethod: the notification (callback) method of the interested object
	*/
	SetNotifyMethod(notifyMethod func(notification INotification))

	/*
	  Set the notification context (self) of the interested object.
	*/
	SetNotifyContext(notifyContext interface{})

	/*
	  Notify the interested object.

	  - parameter notification: the INotification to pass to the interested object's notification method
	*/
	NotifyObserver(notification INotification)

	/*
	  Compare the given object to the notificaiton context object.

	  - parameter object: the object to compare.
	  - returns: boolean indicating if the notification context and the object are the same.
	*/
	CompareNotifyContext(object interface{}) bool
}

IObserver The interface definition for a PureMVC Observer.

In PureMVC, IObserver implementors assume these responsibilities:

* Encapsulate the notification (callback) method of the interested object.

* Encapsulate the notification context (self) of the interested object.

* Provide methods for setting the interested object' notification method and context.

* Provide a method for notifying the interested object.

PureMVC does not rely upon underlying event models such as the one provided with Flash, and ActionScript 3 does not have an inherent event model.

The Observer Pattern as implemented within PureMVC exists to support event driven communication between the application and the actors of the MVC triad.

An Observer is an object that encapsulates information about an interested object with a notification method that should be called when an INotification is broadcast. The Observer then acts as a proxy for notifying the interested object.

Observers can receive Notifications by having their notifyObserver method invoked, passing in an object implementing the INotification interface, such as a subclass of Notification.

type IProxy

type IProxy interface {
	INotifier

	/*
	  Get the Proxy name
	*/
	GetProxyName() string

	/*
	  Set the data object
	*/
	SetData(data interface{})

	/*
		Get the data object
	*/
	GetData() interface{}

	/*
	  Called by the Model when the Proxy is registered
	*/
	OnRegister()

	/*
	  Called by the Model when the Proxy is removed
	*/
	OnRemove()
}

IProxy The interface definition for a PureMVC Proxy.

In PureMVC, IProxy implementors assume these responsibilities:

* Implement a common method which returns the name of the Proxy.

* Provide methods for setting and getting the data object.

Additionally, IProxys typically:

* Maintain references to one or more pieces of model data.

* Provide methods for manipulating that data.

* Generate INotifications when their model data changes.

* Expose their name as a public static const called NAME, if they are not instantiated multiple times.

* Encapsulate interaction with local or remote services used to fetch and persist model data.

type IView

type IView interface {
	/*
	  Initialize the Multiton View instance.
	*/
	InitializeView()

	/*
	  Register an IObserver to be notified
	  of INotifications with a given name.

	  - parameter notificationName: the name of the INotifications to notify this IObserver of
	  - parameter observer: the IObserver to register
	*/
	RegisterObserver(notificationName string, observer IObserver)

	/*
	  Remove a group of observers from the observer list for a given Notification name.

	  - parameter notificationName: which observer list to remove from
	  - parameter notifyContext: removed the observers with this object as their notifyContext
	*/
	RemoveObserver(notificationName string, notifyContext interface{})

	/*
	  Notify the IObservers for a particular INotification.

	  All previously attached IObservers for this INotification's
	  list are notified and are passed a reference to the INotification in
	  the order in which they were registered.

	  - parameter notification: the INotification to notify IObservers of.
	*/
	NotifyObservers(notification INotification)

	/*
	  Register an IMediator instance with the View.

	  Registers the IMediator so that it can be retrieved by name,
	  and further interrogates the IMediator for its
	  INotification interests.

	  If the IMediator returns any INotification
	  names to be notified about, an Observer is created encapsulating
	  the IMediator instance's handleNotification method
	  and registering it as an Observer for all INotifications the
	  IMediator is interested in.

	  - parameter mediatorName: the name to associate with this IMediator instance
	  - parameter mediator: a reference to the IMediator instance
	*/
	RegisterMediator(mediator IMediator)

	/*
	  Retrieve an IMediator from the View.

	  - parameter mediatorName: the name of the IMediator instance to retrieve.
	  - returns: the IMediator instance previously registered with the given mediatorName.
	*/
	RetrieveMediator(mediatorName string) IMediator

	/*
	  Remove an IMediator from the View.

	  - parameter mediatorName: name of the IMediator instance to be removed.
	  - returns: the IMediator that was removed from the View
	*/
	RemoveMediator(mediatorName string) IMediator

	/*
	  Check if a Mediator is registered or not

	  - parameter mediatorName:
	  - returns: whether a Mediator is registered with the given mediatorName.
	*/
	HasMediator(mediatorName string) bool
}

IView The interface definition for a PureMVC View.

In PureMVC, IView implementors assume these responsibilities:

In PureMVC, the View class assumes these responsibilities:

* Maintain a cache of IMediator instances.

* Provide methods for registering, retrieving, and removing IMediators.

* Managing the observer lists for each INotification in the application.

* Providing a method for attaching IObservers to an INotification's observer list.

* Providing a method for broadcasting an INotification.

* Notifying the IObservers of a given INotification when it broadcast.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL