Skip to content

Commit

Permalink
v0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelin2025 committed Oct 15, 2017
1 parent 93e9d17 commit 33bcab4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apicase-core",
"version": "0.1.3",
"version": "0.2.0",
"description": "Core library to make API calls with any adapter",
"author": "Anton Kosykh",
"main": "dist/index.js",
Expand Down
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ const Apicase: Types.Apicase = {
},

// Modify apicase object
install (installer) {
install (installer, options) {
this.bus.emit('preinstall', this)
installer(this)
installer(this, options)
this.bus.emit('postinstall', this)
},

// Get a copy of apicase with modified state
extend (installer) {
extend (installer, options) {
const instance = clone(this)
instance.install(installer)
instance.install(installer, options)
return instance
},

Expand Down Expand Up @@ -92,7 +92,8 @@ const Apicase: Types.Apicase = {
done: data => pipeM(handle('success'), success)({ data, options }),
fail: reason => pipeM(handle('error'), error)({ reason, options }),
another: (name, data, fail = false) =>
pipeM(handle(name), ...(fail ? [reject] : []))(data)
pipeM(handle(name), ...(fail ? [reject] : []))(data),
instance: this
})
})
},
Expand Down
9 changes: 5 additions & 4 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ export type Adapter<Options> = (query: {
options: Options,
done: (data: mixed) => void,
fail: (reason: mixed) => void,
another: (hookType: string, data: mixed, reject?: boolean) => void
another: (hookType: string, data: mixed, reject?: boolean) => void,
instance: Apicase
}) => void

export type Plugin = (instance: Apicase) => void
export type Plugin = (instance: Apicase, options: any) => void

export type Apicase = {
base: {
Expand All @@ -56,8 +57,8 @@ export type Apicase = {
call: (options: AllOptions) => Promise<mixed>,
all: (options: AllOptions[]) => Promise<mixed>,
of: (options: AllOptions) => Apicase,
install: (installer: Plugin) => void,
extend: (installer: Plugin) => Apicase,
install: (installer: Plugin, options: any) => void,
extend: (installer: Plugin, options: any) => Apicase,
on: (event: EventName, callback: (...args: any[]) => void) => void,
// For plugins
[string]: any
Expand Down

0 comments on commit 33bcab4

Please sign in to comment.