本文整理汇总了TypeScript中common.Prop类的典型用法代码示例。如果您正苦于以下问题:TypeScript Prop类的具体用法?TypeScript Prop怎么用?TypeScript Prop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Prop类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: ctrl
export function ctrl(initChapters: StudyChapterMeta[], send: SocketSend, setTab: () => void, chapterConfig, root: AnalyseCtrl): StudyChaptersCtrl {
const list: Prop<StudyChapterMeta[]> = prop(initChapters);
const newForm = chapterNewForm(send, list, setTab, root);
const editForm = chapterEditForm(send, chapterConfig, root.redraw);
const localPaths: LocalPaths = {};
return {
newForm,
editForm,
list,
get(id) {
return list().find(c => c.id === id);
},
size() {
return list().length;
},
sort(ids) {
send("sortChapters", ids);
},
firstChapterId() {
return list()[0].id;
},
toggleNewForm() {
if (newForm.vm.open || list().length < 64) newForm.toggle();
else alert("You have reached the limit of 64 chapters per study. Please create a new study.");
},
localPaths
};
}
开发者ID:ddugovic,项目名称:lila,代码行数:32,代码来源:studyChapters.ts
示例2: ctrl
export function ctrl(send: SocketSend, members: Prop<StudyMemberMap>, setTab: () => void, redraw: () => void) {
const open = prop(false);
let followings = [];
let spectators = [];
function updateFollowings(f) {
followings = f(followings);
if (open()) redraw();
};
return {
open,
candidates() {
const existing = members();
return followings.concat(spectators).filter(function(elem, idx, arr) {
return arr.indexOf(elem) >= idx && // remove duplicates
!existing.hasOwnProperty(titleNameToId(elem)); // remove existing members
}).sort();
},
members,
setSpectators(usernames) {
spectators = usernames;
},
setFollowings(usernames) {
updateFollowings(_ => usernames)
},
delFollowing(username) {
updateFollowings(function(prevs) {
return prevs.filter(function(u) {
return username !== u;
});
});
},
addFollowing(username) {
updateFollowings(function(prevs) {
return prevs.concat([username]);
});
},
toggle() {
open(!open());
if (open()) send('following_onlines');
},
invite(titleName) {
send("invite", titleNameToId(titleName));
setTab();
},
redraw
};
};
开发者ID:ornicar,项目名称:lila,代码行数:47,代码来源:inviteForm.ts
示例3: requestAnalysisButton
function requestAnalysisButton(ctrl: AnalyseController, inProgress: Prop<boolean>, notify: (msg: string) => void) {
if (inProgress()) return h('p', 'Server-side analysis in progress');
if (ctrl.ongoing || ctrl.synthetic) return undefined;
return h('button', {
hook: bind('click', _ => {
$.ajax({
method: 'post',
url: `/${ctrl.data.game.id}/request-analysis`,
success: () => {
inProgress(true);
notify('Server-side analysis in progress')
},
error: () => notify('Cannot run server-side analysis'),
});
})
}, 'Request a computer analysis');
}
开发者ID:ornicar,项目名称:lila,代码行数:17,代码来源:nvui.ts
示例4: submitMultiPgn
function submitMultiPgn(d) {
if (d.pgn) {
const lines = d.pgn.split('\n');
const parts = lines.map(function(l, i) {
// ensure 2 spaces after each game
if (!l.trim() && i && lines[i - 1][0] !== '[') return '\n';
return l;
}).join('\n').split('\n\n\n').map(function(part) {
// remove empty lines in each game
return part.split('\n').filter(identity).join('\n');
}).filter(identity); // remove empty games
if (parts.length > 1) {
if (parts.length > multiPgnMax && !confirm('Import the first ' + multiPgnMax + ' of the ' + parts.length + ' games?')) return;
const step = function(ds) {
if (ds.length) {
send('addChapter', ds[0]);
setTimeout(function() {
step(ds.slice(1));
}, 600);
} else {}
};
const firstIt = vm.initial() ? 1 : (chapters().length + 1);
step(parts.slice(0, multiPgnMax).map(function(pgn, i) {
return {
initial: !i && vm.initial(),
mode: d.mode,
name: 'Chapter ' + (firstIt + i),
orientation: d.orientation,
pgn,
variant: d.variant,
sticky: root.study!.vm.mode.sticky
};
}));
return true;
}
}
};
开发者ID:lexisvar,项目名称:lila,代码行数:37,代码来源:chapterNewForm.ts
示例5: inProgress
success: () => {
inProgress(true);
notify('Server-side analysis in progress')
},
开发者ID:ornicar,项目名称:lila,代码行数:4,代码来源:nvui.ts
注:本文中的common.Prop类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论