mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-11 14:53:12 +00:00
feat: add push to List
This commit is contained in:
parent
43cb9cc6db
commit
99278b1e22
1 changed files with 11 additions and 0 deletions
|
@ -625,6 +625,17 @@ impl List {
|
|||
self.with_event(ctx, |x| x.insert(ctx, pos, value))
|
||||
}
|
||||
|
||||
pub fn push<C: Context, P: Prelim>(
|
||||
&mut self,
|
||||
ctx: &C,
|
||||
value: P,
|
||||
) -> Result<Option<ContainerID>, LoroError> {
|
||||
self.with_event(ctx, |x| {
|
||||
let pos = x.values_len();
|
||||
x.insert(ctx, pos, value)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete<C: Context>(&mut self, ctx: &C, pos: usize, len: usize) -> Result<(), LoroError> {
|
||||
self.with_event(ctx, |list| Ok((list.delete(ctx, pos, len), ())))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue