Wikia

WoWWiki

Bazaar (AddOn)

Talk0
100,577pages on
this wiki

Redirected from AddOn Bazaar

Addonicon
WoWWiki Hosted AddOn Page (Old)
This AddOn is currently considered old. Content is retained for reference or subsequent updates.
Bazaar
Details
Links
HostsWoWI
Google

Bazaar is an addon that makes syncing addon configurations between users easier by doing the heavy lifting of communicating the syncs and changing the data into a format that can be sent through addon channels.

This is not a library and cannot be embedded, you will have to add Bazaar as an optional dependency to your TOC file and check if it was loaded before registering, users can download Bazaar at the below link if they are using an addon that supports Bazaar.

Download Bazaar at WoWInterface
Bazaar SVN

Bazaar APIEdit

Bazaar:RegisterAddOn(name)Edit

ArgsEdit

Arg Type Details
key string Category key for seeing if it was selected
name string Addon folder name

ReturnsEdit

Return Type Details
BazaarObj table The Bazaar Object encapsulating the Bazaar API's.

Bazaar Object APIEdit

BazaarObj:RegisterCategory(key, displayName)Edit

ArgsEdit

Arg Type Details
key string Category key for seeing if it was selected
displayName string Display name for the category when selected categories to sync

RemarksEdit

Registers a category of configuration for this BazaarObj.

The characters \001 - \004 are reserved for communications handling.

Bazaar specifically makes sure the categories are valid before syncing them, meaning if in the future you add another one or remove it we won't let the user sync those categories with someone using a newer or older version.

BazaarObj:RegisterSendHandler(handler[, func])Edit

ArgsEdit

Arg Type Details
handler string/function/table Function/method to call.
func string/function (Optional) Function to call if you're using a handler

RemarksEdit

Registers the passed handler/function to be called when we need the data that should be serialized and synced.

If you passed just a function it'll be called as func(categories) If you passed a handler and a function it'll be called as handler[func](handler, categories)

categories is a dictionary table of the category keys that were selected.

The send handler MUST return either a string, number, table or boolean it's recommended you use a table as that's easier to work with when you need to load the data in the receive handler.

BazaarObj:RegisterReceiveHandler(handler[, func])Edit

ArgsEdit

Arg Type Details
handler string/function/table Function/method to call.
func string/function (Optional) Function to call if you're using a handler

RemarksEdit

Registers the passed handler/function to be called when we have data that was packed from the send handler

If you passed just a function it'll be called as func(data, categories) If you passed a handler and a function it'll be called as handler[func](handler, data, categories)

categories is a dictionary table of the category keys that were selected.

If you return a string from the receive handler then a custom message will be displayed when the configuration syncing is done, you can use this if you need to give any additional information to the user like they might have to reload the interface.

ExampleEdit

The below is an example of a simple implementation of Bazaar support.

if( IsAddOnLoaded("Bazaar") ) then
	local Config = {}
	function Config:Receive(data, categories)
		for key in pairs(categories) do
			Foo.db.profile[key] = data[key]
		end
		Foo:Reload()
	end
	function Config:Send(categories)
		local config = {}
		for key in pairs(categories) do
			config[key] = CopyTable(Foo.db.profile[key])
		end
		return config
	end
	local obj = Bazaar:RegisterAddOn("Afflicted")
	obj:RegisterCategory("general", "General")
	obj:RegisterCategory("frames", "Frames")
	obj:RegisterCategory("apples", "Apples")
	obj:RegisterReceiveHandler(Config, "Receive")
	obj:RegisterSendHandler(Config, "Send")
end

Around Wikia's network

Random Wiki