AddOn Bazaar

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

Remarks
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.

Remarks
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.

Remarks
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.

Example
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