本文整理汇总了TypeScript中@ephox/katamari.Future.nu方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Future.nu方法的具体用法?TypeScript Future.nu怎么用?TypeScript Future.nu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Future
的用法示例。
在下文中一共展示了Future.nu方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createPartialChoiceMenu
fetch: (comp) => {
return Future.nu((callback) => {
return spec.fetch(callback);
}).map((items) => {
return Option.from(createTieredDataFrom(
Merger.deepMerge(
createPartialChoiceMenu(
Id.generate('menu-value'),
items,
(value) => {
spec.onItemAction(comp, value);
},
spec.columns,
spec.presets,
ItemResponse.CLOSE_ON_EXECUTE,
// No colour is ever selected on opening
() => false,
sharedBackstage.providers
),
{
movement: deriveMenuMovement(spec.columns, spec.presets)
}
)
));
});
},
示例2: function
const moveOnlyScroll = function (element, destination) {
return Future.nu(function (callback) {
const getCurrent = Fun.curry(getScrollTop, element);
Attr.set(element, lastScroll, getCurrent());
const update = function (newScroll, abort) {
const previous = DataAttributes.safeParse(element, lastScroll);
// As soon as we detect a scroll value that we didn't set, assume the user
// is scrolling, and abort the scrolling.
if (previous !== element.dom().scrollTop) {
abort(element.dom().scrollTop);
} else {
element.dom().scrollTop = newScroll;
Attr.set(element, lastScroll, newScroll);
}
};
const finish = function (/* dest */) {
element.dom().scrollTop = destination;
Attr.set(element, lastScroll, destination);
callback(destination);
};
// Identify the number of steps based on distance (consistent time)
const distance = Math.abs(destination - getCurrent());
const step = Math.ceil(distance / NUM_TOP_ANIMATION_FRAMES);
animator.animate(getCurrent, destination, step, update, finish, ANIMATION_RATE);
});
};
示例3: function
const check = function (label, initial, destination, amount) {
return Future.nu(function (callback) {
let current = initial;
let values = [ current ];
const add = function (val, abort) {
if (val > 100) {
abort('abort');
} else {
current = val;
values = values.concat([ val ]);
}
};
animator.animate(function () {
return current;
}, destination, amount, add, function (s) {
add(s, Fun.identity);
callback({
label,
info: {
current,
values
}
});
}, 2);
});
};
示例4: return
return (comp: AlloyComponent): Future<Option<TieredData>> => {
return Future.nu((callback) => {
return spec.fetch(callback);
}).map((items) => {
return Option.from(createTieredDataFrom(
Merger.deepMerge(
createPartialChoiceMenu(
Id.generate('menu-value'),
items,
(value) => {
spec.onItemAction(getApi(comp), value);
},
spec.columns,
spec.presets,
ItemResponse.CLOSE_ON_EXECUTE,
spec.select.getOr(() => false),
providersBackstage
),
{
movement: deriveMenuMovement(spec.columns, spec.presets),
menuBehaviours: SimpleBehaviours.unnamedEvents(spec.columns !== 'auto' ? [ ] : [
AlloyEvents.runOnAttached((comp, se) => {
detectSize(comp, 4, classForPreset(spec.presets)).each(({ numRows, numColumns }) => {
Keying.setGridSize(comp, numRows, numColumns);
});
})
])
} as TieredMenuTypes.PartialMenuSpec
)
));
});
};
示例5: function
const loadF = function (url) {
return Future.nu(function (resolve) {
load(
url,
Fun.compose(resolve, Fun.constant(Result.value(url))),
Fun.compose(resolve, Fun.constant(Result.error(url)))
);
});
};
示例6: completer
const collect = (editor): Future<ImageDialogInfo> => {
const urlListSanitizer = ListUtils.sanitizer((item) => {
return editor.convertURL(item.value || item.url, 'src');
});
const futureImageList = Future.nu<Option<ListItem[]>>((completer) => {
Utils.createImageList(editor, (imageList) => {
completer(
urlListSanitizer(imageList).map(
(items) => Arr.flatten([
[{ text: 'None', value: '' }],
items
])
)
);
});
});
const classList = ListUtils.sanitize(Settings.getClassList(editor));
const hasAdvTab = Settings.hasAdvTab(editor);
const hasUploadUrl = Settings.hasUploadUrl(editor);
const hasUploadHandler = Settings.hasUploadHandler(editor);
const image = readImageDataFromSelection(editor);
const hasDescription = Settings.hasDescription(editor);
const hasImageTitle = Settings.hasImageTitle(editor);
const hasDimensions = Settings.hasDimensions(editor);
const hasImageCaption = Settings.hasImageCaption(editor);
const url = Settings.getUploadUrl(editor);
const basePath = Settings.getUploadBasePath(editor);
const credentials = Settings.getUploadCredentials(editor);
const handler = Settings.getUploadHandler(editor);
const prependURL: Option<string> = Option.some(Settings.getPrependUrl(editor)).filter(
(preUrl) => Type.isString(preUrl) && preUrl.length > 0);
return futureImageList.map((imageList): ImageDialogInfo => {
return {
image,
imageList,
classList,
hasAdvTab,
hasUploadUrl,
hasUploadHandler,
hasDescription,
hasImageTitle,
hasDimensions,
hasImageCaption,
url,
basePath,
credentials,
handler,
prependURL
};
});
};
示例7: resolve
return Futures.mapM(items, (item: any) => {
return Future.nu((resolve) => {
const blob = item.getAsFile ? item.getAsFile() : item;
const reader = new window.FileReader();
reader.onload = () => {
resolve({
blob,
uri: reader.result
});
};
reader.readAsDataURL(blob);
});
});
示例8: return
return (entry: UrlData): Future<UrlData> => {
return Future.nu((completer) => {
const handler = (value: string, meta?: Record<string, any>) => {
if (!Type.isString(value)) {
throw new Error('Expected value to be string');
}
if (meta !== undefined && !Type.isObject(meta)) {
throw new Error('Expected meta to be a object');
}
const r: UrlData = { value, meta };
completer(r);
};
const meta = Tools.extend({ filetype }, Option.from(entry.meta).getOr({}));
// file_picker_callback(callback, currentValue, metaData)
picker.call(editor, handler, entry.value, meta);
});
};